Description:
This .Rmd will include exploratory data analyses (EDA) on the phenotypic plasticity of traits measured in four populations of Nemophila menziesii during the 2021-2022 growing season of the Mazer lab’s Nemophila project.

Load Packages

library(tidyverse) #For data organization and tidying
library(janitor) #more tidying functions
library(here) #great for specifying relative file paths
library(lubridate) #for adjusting 'date' values if any need cleaning up
library(lme4)
library(car)
library(corrplot)
library(jtools)
library(MuMIn) # for R2s in lmer
library(lmerTest) #get P-values from lmer - must load lme4
#Provides p-values using Satterthwaite's approximation via t-test
#set contrasts
options(contrasts=c(unordered="contr.sum", ordered="contr.poly"))
#DOUBLE CHECK this is correct for the below analyses

Load Fitness Plant Data

Bodega Bay

Load and tidy up data.

## All data
BB_allplants <- read_csv(here::here("data_sheets", "compiled_sheets", "BB_mastersheet_full_2023-03-11.csv")) %>% select(-c(Sequence, Co., FitP, F_multi, F_plant_notes, Fl_2.25:flr_P, seeds_weighed_d1:msm_d9)) %>% 
  filter(Replicated == "R") %>% #Replicated genotypes only
  mutate(fl_duration = case_when(fl_duration == 0 ~ 1,
                                 TRUE ~ fl_duration)) %>%  #Replace durations of 0 with 1
  mutate(FFD_c = scale(yday(FFD), scale = FALSE)[,1], #convert to Julian day of year, but don't scale...
         fl_dur_c = scale(fl_duration, scale = FALSE)[,1], # Center all variables
         corolla_d_c = scale(corolla_diam_mm, scale = FALSE)[,1],
         AG_biom_c = scale(AG_biomass_mg, scale = FALSE)[,1],
         seed_ct_c = scale(seed_ct, scale = FALSE)[,1],
         lifet_fec_c = scale(total_est_seed_production, scale = FALSE)[,1]) %>% 
  mutate(FFD_z = scale(yday(FFD))[,1],
         fl_dur_z = scale(fl_duration)[,1], # Standardize all variables
         corolla_d_z = scale(corolla_diam_mm)[,1],
         AG_biom_z = scale(AG_biomass_mg)[,1],
         seed_ct_z = scale(seed_ct)[,1],
         lifet_fec_z = scale(total_est_seed_production)[,1]) %>% 
  mutate(seed_ct_r = seed_ct/mean(seed_ct),
         lifet_fec_r = total_est_seed_production/mean(total_est_seed_production)) %>% #fitness relative to population mean
  mutate(Treatment = as.factor(case_when(Block %in% c("1", "2", "3") ~ "ambient",
                               Block == "W" ~ "watered")),
         Treat_bin = as.numeric(case_when(Block %in% c("1", "2", "3") ~ 0, #binary var for treatment: ambient/watered = 0/1
                               Block == "W" ~ 1))) %>% 
  mutate(Recipient = as.factor(Recipient))
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 3856 Columns: 84
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (6): Block, Donor, Recipient, Replicated, F_plant_notes, notes_corolla
## dbl  (50): Location, Sequence, Co., Plant_ID, F_plant, closed_fruits_F, open...
## num   (1): F_multi
## lgl   (7): FitP, Rep_FitP, any_FitP, Fl_5.4, seeds_weighed_d1, seed_mass_mg_...
## date (20): Germ_Date, Sow_Date, Plant_Date, Fl_2.25, Fl_3.3, Fl_3.11, Fl_3.1...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
BB_allplants_f <- BB_allplants %>% 
  filter(!is.na(FFD_c)) #plants that flowered only

#318 obs vs 225 for fitness plants

##Fitness Plants Only
BB_Fplants <- BB_allplants %>% 
  filter(any_FitP == TRUE)

##Note on the data:
## This data frame includes data on all selected fitness plants at Bodega Bay from 2021-2022. There were 3 experimental blocks and a total of 156 (+1; 160) point-locations. Plants in block 'W' received supplemental water and had, when available, 3 fitness plants chosen. Recipient ID's (Genotypes) that were present in both the regular and water blocks had, when available, 3 fitness plants chosen (Replicated = R). Important trait-related columns include germination date, the number of closed fruit, number of total fruit, seed count, mean seed mass (msm_all), mean seeds per fruit, total estimated seed production, first flowering date (FFD), days from germination to flower, flowering duration, and survival.




######
## Exclude genotypes without observations from both treatments???

Correlations

corrplot(cor(na.omit(select(BB_allplants, c(seed_ct, lifet_fec_c, FFD_c, fl_dur_c, corolla_d_c, AG_biom_c)))), addCoef.col = "white", number.cex = 0.8, method = "square")

John M’s Models

Statistical approaches matched to each of John’s research questions for investigating plasticity in N. menziesii:

  1. What is the effect of supplemental water on functional traits and fitness in Nemophila menziesii?

I.e.: What is the magnitude & direction of plastic changes in traits between ambient (dry) and watered plots?

Variable Treatment: All traits mean-centered

Analysis: Linear Regression - calculate Regression coefficients for Trait ~ Treatment Models: - Bivariate - Bivariate + random effects

Positive coefficients = increased value in watered treatment

Statistical Tests

Fecundity

#Fecundity - seed count ^
PL_fec_lm1 <- lm(seed_ct_c ~ Treatment, data = BB_Fplants)
summary(PL_fec_lm1)
## 
## Call:
## lm(formula = seed_ct_c ~ Treatment, data = BB_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
##  -4.011  -3.011  -1.692  -0.011 114.989 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.1359     0.6041   3.536 0.000494 ***
## Treatment1   -1.1591     0.6041  -1.919 0.056288 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.951 on 223 degrees of freedom
## Multiple R-squared:  0.01624,    Adjusted R-squared:  0.01183 
## F-statistic: 3.682 on 1 and 223 DF,  p-value: 0.05629
PL_fec_lm1_r <- lmer(seed_ct_c ~ Treatment + (1|Recipient) + (1|Block), data = BB_Fplants)
## boundary (singular) fit: see help('isSingular')
summary(PL_fec_lm1_r)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: seed_ct_c ~ Treatment + (1 | Recipient) + (1 | Block)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 1619.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -0.8344 -0.3637 -0.1478  0.0028 12.7071 
## 
## Random effects:
##  Groups    Name        Variance  Std.Dev. 
##  Recipient (Intercept) 3.022e+00 1.738e+00
##  Block     (Intercept) 3.143e-14 1.773e-07
##  Residual              7.723e+01 8.788e+00
## Number of obs: 225, groups:  Recipient, 21; Block, 4
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)   
## (Intercept)   2.1140     0.7065  20.2917   2.992  0.00713 **
## Treatment1   -1.1365     0.5964 213.3403  -1.905  0.05807 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.131
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
r.squaredGLMM(PL_fec_lm1_r)
## Warning: 'r.squaredGLMM' now calculates a revised statistic. See the help page.
##             R2m        R2c
## [1,] 0.01552997 0.05260255
#### NS
# MV - Control for FFD and biomass 
PL_fec_lm1_mv <- lm(seed_ct_c ~ Treatment + FFD_c + AG_biom_c, data = BB_Fplants)
summary(PL_fec_lm1_mv)
## 
## Call:
## lm(formula = seed_ct_c ~ Treatment + FFD_c + AG_biom_c, data = BB_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.1201 -2.4935 -1.1179  0.7216 23.1907 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.12287    0.54263   3.912 0.000185 ***
## Treatment1   0.13176    0.55602   0.237 0.813257    
## FFD_c       -0.08069    0.05289  -1.526 0.130834    
## AG_biom_c    0.06851    0.02884   2.376 0.019795 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5 on 84 degrees of freedom
##   (137 observations deleted due to missingness)
## Multiple R-squared:  0.1132, Adjusted R-squared:  0.08157 
## F-statistic: 3.576 on 3 and 84 DF,  p-value: 0.0173
PL_fec_lm1_mvr <- lmer(seed_ct_c ~ Treatment  + FFD_c + AG_biom_c + (1|Recipient) + (1|Block), data = BB_Fplants)
summary(PL_fec_lm1_mvr)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: seed_ct_c ~ Treatment + FFD_c + AG_biom_c + (1 | Recipient) +  
##     (1 | Block)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 533.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.0490 -0.4178 -0.1186  0.2020  4.2027 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  3.373   1.837   
##  Block     (Intercept)  2.615   1.617   
##  Residual              20.760   4.556   
## Number of obs: 88, groups:  Recipient, 21; Block, 4
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)  
## (Intercept)  1.991268   1.142666  1.626195   1.743   0.2513  
## Treatment1  -0.003963   1.072365  1.289670  -0.004   0.9975  
## FFD_c       -0.092686   0.051878 83.276912  -1.787   0.0776 .
## AG_biom_c    0.062761   0.027592 79.514380   2.275   0.0256 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr) Trtmn1 FFD_c 
## Treatment1 -0.378              
## FFD_c       0.063  0.053       
## AG_biom_c   0.011  0.130  0.249
r.squaredGLMM(PL_fec_lm1_mvr)
##            R2m       R2c
## [1,] 0.1042285 0.3047775
ranef(PL_fec_lm1_mvr)
## $Recipient
##        (Intercept)
## BB_017 -0.10595996
## BB_020 -1.11681236
## BB_024  1.21798970
## BB_032  0.09642399
## BB_049 -1.10254810
## BB_051 -0.70900447
## BB_059  0.17028877
## BB_061 -0.16347939
## BB_077 -0.08442317
## BB_079 -0.65350623
## BB_085 -0.92927360
## BB_102  2.45680331
## BB_105 -0.19905943
## BB_118 -0.06730679
## BB_137 -0.12378161
## BB_143  3.36680614
## BB_152  0.02660540
## BB_161 -0.32969793
## BB_164 -0.41351878
## BB_185 -1.04030775
## BB_187 -0.29623774
## 
## $Block
##     (Intercept)
## 1  9.689345e-01
## 2 -1.477737e+00
## 3  5.088026e-01
## W -2.474189e-14
## 
## with conditional variances for "Recipient" "Block"
#Error boundary (singular) fit: may indicate that a component has very little effect on the outcome variable - remove it
#Location as random effect removed from this model


#
#
#####
#Fecundity - lifetime ^

PL_fec_lm2 <- lm(lifet_fec_c ~ Treatment, data = BB_Fplants)
summary(PL_fec_lm2)
## 
## Call:
## lm(formula = lifet_fec_c ~ Treatment, data = BB_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
##  -6.184  -5.184  -2.215  -1.184 220.998 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)   0.3087     1.0988   0.281   0.7790  
## Treatment1   -1.9846     1.0988  -1.806   0.0723 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 16.28 on 223 degrees of freedom
## Multiple R-squared:  0.01442,    Adjusted R-squared:  0.009997 
## F-statistic: 3.262 on 1 and 223 DF,  p-value: 0.07225
PL_fec_lm2_r <- lmer(lifet_fec_c ~ Treatment + (1|Recipient) + (1|Location), data = BB_Fplants)
summary(PL_fec_lm2_r)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: lifet_fec_c ~ Treatment + (1 | Recipient) + (1 | Location)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 1887
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -0.7073 -0.2983 -0.1117 -0.0468 13.3644 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Location  (Intercept)   5.949   2.439  
##  Recipient (Intercept)   5.489   2.343  
##  Residual              253.808  15.931  
## Number of obs: 225, groups:  Location, 66; Recipient, 21
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)
## (Intercept)    0.225      1.254 19.516   0.179    0.859
## Treatment1    -1.901      1.145 67.523  -1.660    0.101
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.181
r.squaredGLMM(PL_fec_lm2_r)
##             R2m        R2c
## [1,] 0.01318099 0.05573669
ranef(PL_fec_lm2_r)
## $Location
##       (Intercept)
## 2    -0.025515681
## 4     1.003901117
## 5     0.260318423
## 8    -0.092887919
## 9    -0.015638523
## 10   -0.087728319
## 15   -0.038871455
## 20    0.026297671
## 26   -0.115110056
## 30    0.523763945
## 34    1.030757173
## 39   -0.133578209
## 40   -0.130170194
## 44    0.080905039
## 46   -0.240882277
## 47   -0.095718481
## 50   -0.173533982
## 52   -0.104517969
## 53   -0.127895271
## 59   -0.199454623
## 60   -0.395516606
## 62   -0.067705359
## 64    0.004984936
## 67   -0.041729885
## 70   -0.486111933
## 73   -0.137414357
## 76   -0.083128027
## 77   -0.145307605
## 79   -0.046565701
## 80.5 -0.325411953
## 83   -0.044561356
## 84   -0.112113448
## 85    0.054530247
## 86   -0.113115824
## 87   -0.032380963
## 88   -0.103240848
## 90   -0.872359541
## 91   -0.033367705
## 99    0.025307130
## 100  -0.275342177
## 107  -0.101041164
## 109  -0.137414357
## 110  -0.696506390
## 112  -0.042515987
## 113  -0.044584615
## 114  -0.145307605
## 115  -0.025513500
## 119  -0.069530386
## 120   4.466199333
## 122  -0.162126545
## 125  -0.008116157
## 129  -0.092887919
## 130  -0.524132759
## 132  -0.049702000
## 134  -0.113118005
## 136  -0.111506521
## 140  -0.617996746
## 141  -0.075905040
## 143   0.422373097
## 144   0.107328183
## 146   0.196345035
## 147  -0.039083032
## 150  -0.584379957
## 151  -0.004065950
## 155   0.247800594
## 160   0.091498961
## 
## $Recipient
##         (Intercept)
## BB_017  0.023472759
## BB_020 -0.343340409
## BB_024  3.785082769
## BB_032 -0.002925389
## BB_049 -0.757686550
## BB_051 -0.623755736
## BB_059 -0.319482004
## BB_061 -0.517387904
## BB_077 -0.492893832
## BB_079 -0.044516714
## BB_085 -0.492860637
## BB_102  1.130353510
## BB_105 -0.181450277
## BB_118 -0.267946271
## BB_137 -0.800768554
## BB_143  0.821208263
## BB_152  0.253063859
## BB_161 -0.358264418
## BB_164 -0.392586330
## BB_185  0.090834162
## BB_187 -0.508150298
## 
## with conditional variances for "Location" "Recipient"
#Block as random results in singular model


#
#MV - Control for FFD and biomass
PL_fec_lm2_mv <- lm(lifet_fec_c ~ Treatment + FFD_c + AG_biom_c, data = BB_Fplants)
summary(PL_fec_lm2_mv)
## 
## Call:
## lm(formula = lifet_fec_c ~ Treatment + FFD_c + AG_biom_c, data = BB_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -11.116  -3.677  -1.779   0.075  40.380 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  0.13327    0.87979   0.151   0.8800  
## Treatment1  -0.21397    0.90150  -0.237   0.8130  
## FFD_c       -0.12890    0.08575  -1.503   0.1365  
## AG_biom_c    0.08492    0.04676   1.816   0.0729 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.107 on 84 degrees of freedom
##   (137 observations deleted due to missingness)
## Multiple R-squared:  0.08681,    Adjusted R-squared:  0.0542 
## F-statistic: 2.662 on 3 and 84 DF,  p-value: 0.05327
PL_fec_lm2_mvr <- lmer(lifet_fec_c ~ Treatment + FFD_c + AG_biom_c + (1|Recipient) + (1|Block), data = BB_Fplants)
summary(PL_fec_lm2_mvr)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: lifet_fec_c ~ Treatment + FFD_c + AG_biom_c + (1 | Recipient) +  
##     (1 | Block)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 616.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.7165 -0.3887 -0.2122  0.0883  4.6956 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  6.250   2.500   
##  Block     (Intercept)  1.211   1.101   
##  Residual              58.966   7.679   
## Number of obs: 88, groups:  Recipient, 21; Block, 4
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)
## (Intercept)  0.04198    1.20532  1.07232   0.035    0.978
## Treatment1  -0.35155    1.08499  0.71458  -0.324    0.816
## FFD_c       -0.13376    0.08550 83.91672  -1.564    0.121
## AG_biom_c    0.07397    0.04588 81.64165   1.612    0.111
## 
## Correlation of Fixed Effects:
##            (Intr) Trtmn1 FFD_c 
## Treatment1 -0.217              
## FFD_c       0.098  0.083       
## AG_biom_c   0.024  0.214  0.256
r.squaredGLMM(PL_fec_lm2_mvr)
##             R2m      R2c
## [1,] 0.07676031 0.180458
ranef(PL_fec_lm2_mvr)
## $Recipient
##        (Intercept)
## BB_017  0.66624163
## BB_020 -1.08311684
## BB_024  1.09506729
## BB_032  0.03435655
## BB_049 -1.30324686
## BB_051 -1.24949691
## BB_059 -0.04859059
## BB_061 -0.39138754
## BB_077 -0.55062155
## BB_079 -0.88428858
## BB_085 -1.09942692
## BB_102  2.04770180
## BB_105 -0.26847738
## BB_118 -0.25500907
## BB_137 -0.31897591
## BB_143  4.29098186
## BB_152  1.48673379
## BB_161 -0.21719215
## BB_164 -0.45942288
## BB_185 -1.04609324
## BB_187 -0.44573650
## 
## $Block
##     (Intercept)
## 1  4.336269e-01
## 2 -5.966581e-01
## 3  1.630312e-01
## W -2.980296e-16
## 
## with conditional variances for "Recipient" "Block"

First Flowering Date

#FFD
PL_FFD_lm1 <- lm(FFD_c ~ Treatment, data = BB_allplants)
summary(PL_FFD_lm1)
## 
## Call:
## lm(formula = FFD_c ~ Treatment, data = BB_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -27.056  -7.056   0.944   8.432  49.595 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.07778    0.68269  -0.114    0.909
## Treatment1   0.32544    0.68269   0.477    0.634
## 
## Residual standard error: 11.82 on 316 degrees of freedom
##   (522 observations deleted due to missingness)
## Multiple R-squared:  0.0007186,  Adjusted R-squared:  -0.002444 
## F-statistic: 0.2272 on 1 and 316 DF,  p-value: 0.6339
#Genotype as main effect
#PL_FFD_lm1_m <- lm(FFD_c ~ Treatment + Recipient + Location, data = BB_allplants)
#summary(PL_FFD_lm1_m)

PL_FFD_lm1_r <- lmer(FFD_c ~ Treatment + (1|Recipient) + (1|Location), data = BB_allplants)
summary(PL_FFD_lm1_r)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: FFD_c ~ Treatment + (1 | Recipient) + (1 | Location)
##    Data: BB_allplants
## 
## REML criterion at convergence: 2415.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.0326 -0.6276 -0.1231  0.5090  4.0075 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Location  (Intercept) 51.645   7.186   
##  Recipient (Intercept)  5.187   2.278   
##  Residual              90.963   9.537   
## Number of obs: 318, groups:  Location, 65; Recipient, 21
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)
## (Intercept)    1.870      1.355 33.416   1.380    0.177
## Treatment1    -0.848      1.262 38.615  -0.672    0.506
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.462
r.squaredGLMM(PL_FFD_lm1_r)
##              R2m       R2c
## [1,] 0.004580967 0.3873525
ranef(PL_FFD_lm1_r) #Block removed, doesn't help explain variance - BUT LOCATION explains a LOT of variance...
## $Location
##       (Intercept)
## 2     -3.83327034
## 4     -1.23138885
## 5      1.59919320
## 8     -0.16702018
## 9     -1.56117894
## 10     3.60982642
## 15     9.64240525
## 20    -0.02529969
## 26     2.94145706
## 30     1.59661731
## 34    -3.37831371
## 39     2.01303340
## 40     7.33601403
## 44     2.58571417
## 46    -7.03118180
## 47    -3.39617312
## 50    -4.90643401
## 52    -1.59074347
## 53     2.85402807
## 59    -2.97387544
## 60    -5.48498928
## 62    -5.00954654
## 64    -3.76273004
## 67     4.63568332
## 70    13.49842018
## 73     4.66683791
## 76     1.44782698
## 77     9.03998802
## 79     2.05330323
## 80.5   2.28133220
## 83     3.88440216
## 84     5.18571737
## 85     2.33744616
## 86   -12.84165458
## 87     1.98596278
## 88     0.32905302
## 90     2.54058164
## 99   -11.66449390
## 100   -0.02512620
## 107   -2.30939702
## 109    3.17845634
## 110    4.17762700
## 112   10.60866185
## 113    3.45661703
## 114    9.96120712
## 115   -1.52030617
## 119   12.36840662
## 120  -10.68870378
## 122   -6.15137793
## 125    2.39613114
## 129   -4.69689475
## 130   -6.53464697
## 132   -4.33013498
## 134  -11.08874917
## 136    3.96472176
## 140    2.54972529
## 141    2.70504949
## 143   -4.49234725
## 144   -6.16268930
## 146   -8.11111709
## 147   -2.45162161
## 150    1.99901305
## 151   -0.75482712
## 155    1.08520309
## 160   -8.33943043
## 
## $Recipient
##        (Intercept)
## BB_017 -2.35225741
## BB_020 -0.36810552
## BB_024 -0.60675140
## BB_032  0.82255847
## BB_049 -1.27021717
## BB_051 -1.41044180
## BB_059  1.10693422
## BB_061  1.54421471
## BB_077  0.91620646
## BB_079 -0.87312513
## BB_085 -1.15279262
## BB_102 -0.66164285
## BB_105  0.30841923
## BB_118 -1.83073717
## BB_137  0.43506374
## BB_143  1.01685156
## BB_152  1.02999964
## BB_161  1.94711431
## BB_164  1.36937804
## BB_185  0.08963305
## BB_187 -0.06030239
## 
## with conditional variances for "Location" "Recipient"
AIC(PL_FFD_lm1, PL_FFD_lm1_r)
##              df      AIC
## PL_FFD_lm1    3 2477.302
## PL_FFD_lm1_r  5 2425.506
#Random effects appear to always come out best compared to other models


#Diagnostics
#plot(PL_FFD_lm1_r)

Flowering Duration

#F duration *
PL_Fdur_lm1 <- lm(fl_dur_c ~ Treatment, data = BB_allplants)
summary(PL_Fdur_lm1)
## 
## Call:
## lm(formula = fl_dur_c ~ Treatment, data = BB_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -17.702 -11.685  -3.702   8.315  50.315 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.7190     0.7443   0.966    0.335    
## Treatment1   -3.0086     0.7443  -4.042 6.66e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.89 on 316 degrees of freedom
##   (522 observations deleted due to missingness)
## Multiple R-squared:  0.04917,    Adjusted R-squared:  0.04616 
## F-statistic: 16.34 on 1 and 316 DF,  p-value: 6.656e-05
PL_Fdur_lm1_r <- lmer(fl_dur_c ~ Treatment + (1|Recipient) + (1|Block), data = BB_allplants)
summary(PL_Fdur_lm1_r)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: fl_dur_c ~ Treatment + (1 | Recipient) + (1 | Block)
##    Data: BB_allplants
## 
## REML criterion at convergence: 2522.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.5972 -0.8324 -0.2986  0.6724  3.8561 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)   3.668   1.915  
##  Block     (Intercept)   1.021   1.011  
##  Residual              162.103  12.732  
## Number of obs: 318, groups:  Recipient, 21; Block, 4
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)
## (Intercept)   0.6456     1.0329  1.8344   0.625    0.601
## Treatment1   -2.9882     0.9481  1.3455  -3.152    0.142
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.306
r.squaredGLMM(PL_Fdur_lm1_r)
##            R2m        R2c
## [1,] 0.0481978 0.07495509
ranef(PL_Fdur_lm1_r)
## $Recipient
##        (Intercept)
## BB_017  2.72680330
## BB_020 -0.04658378
## BB_024  0.20043887
## BB_032 -1.26098445
## BB_049 -1.09449326
## BB_051  0.38656042
## BB_059  0.78590414
## BB_061 -0.07625769
## BB_077 -0.25588793
## BB_079  0.75372499
## BB_085  0.71166993
## BB_102  1.15097557
## BB_105 -0.33195352
## BB_118 -0.51717762
## BB_137 -0.21104208
## BB_143 -1.31690756
## BB_152 -0.63880768
## BB_161 -0.92807825
## BB_164  0.11496206
## BB_185  0.76566847
## BB_187 -0.91853393
## 
## $Block
##     (Intercept)
## 1  5.599502e-01
## 2 -5.492580e-02
## 3 -5.050244e-01
## W  4.582317e-15
## 
## with conditional variances for "Recipient" "Block"
#Control for FFD, Biomass
PL_Fdur_lm1_mv <- lm(fl_dur_c ~ Treatment + FFD_c + AG_biom_c, data = BB_allplants)
summary(PL_Fdur_lm1_mv)
## 
## Call:
## lm(formula = fl_dur_c ~ Treatment + FFD_c + AG_biom_c, data = BB_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -26.188  -9.252  -2.012   5.973  44.088 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.38697    1.36401   1.750 0.083733 .  
## Treatment1  -1.12768    1.39912  -0.806 0.422499    
## FFD_c       -0.44976    0.12778  -3.520 0.000696 ***
## AG_biom_c    0.07611    0.04759   1.599 0.113439    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.67 on 85 degrees of freedom
##   (751 observations deleted due to missingness)
## Multiple R-squared:  0.1656, Adjusted R-squared:  0.1362 
## F-statistic: 5.625 on 3 and 85 DF,  p-value: 0.001448
PL_Fdur_lm1_mvr <- lmer(fl_dur_c ~ Treatment + FFD_c + (1|Recipient) + (1|Block), data = BB_allplants)
summary(PL_Fdur_lm1_mvr)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: fl_dur_c ~ Treatment + FFD_c + (1 | Recipient) + (1 | Block)
##    Data: BB_allplants
## 
## REML criterion at convergence: 2455.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.8176 -0.6105 -0.2207  0.3425  4.0310 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)   1.417   1.191  
##  Block     (Intercept)   1.682   1.297  
##  Residual              130.634  11.430  
## Number of obs: 318, groups:  Recipient, 21; Block, 4
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)   0.69766    1.03519   1.61835   0.674    0.584    
## Treatment1   -2.87256    1.00364   1.48214  -2.862    0.144    
## FFD_c        -0.49348    0.05505 283.19461  -8.964   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr) Trtmn1
## Treatment1 -0.368       
## FFD_c      -0.002 -0.014
r.squaredGLMM(PL_Fdur_lm1_mvr)
##            R2m       R2c
## [1,] 0.2416975 0.2592739
ranef(PL_Fdur_lm1_mvr)
## $Recipient
##        (Intercept)
## BB_017  0.85888594
## BB_020 -0.22132215
## BB_024 -0.20414376
## BB_032 -0.11112181
## BB_049 -0.83058872
## BB_051 -0.05001913
## BB_059  0.70930963
## BB_061  0.34014155
## BB_077 -0.09547452
## BB_079  0.43596767
## BB_085 -0.15980348
## BB_102  0.36307391
## BB_105 -0.27104173
## BB_118 -0.44148056
## BB_137 -0.15450315
## BB_143 -0.61732277
## BB_152 -0.48196009
## BB_161  0.11996812
## BB_164  0.49223043
## BB_185  0.45886765
## BB_187 -0.13966301
## 
## $Block
##     (Intercept)
## 1  9.276967e-01
## 2 -1.449036e-01
## 3 -7.827931e-01
## W  2.290691e-14
## 
## with conditional variances for "Recipient" "Block"

Corolla Diameter

#Corolla diam *
PL_Cdiam_lm1 <- lm(corolla_d_c ~ Treatment, data = BB_Fplants)
summary(PL_Cdiam_lm1)
## 
## Call:
## lm(formula = corolla_d_c ~ Treatment, data = BB_Fplants)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.3677  -3.3574   0.1757   3.3192  12.5733 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)   0.2543     0.4186   0.608  0.54452   
## Treatment1   -1.2147     0.4186  -2.902  0.00434 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.687 on 134 degrees of freedom
##   (89 observations deleted due to missingness)
## Multiple R-squared:  0.05912,    Adjusted R-squared:  0.0521 
## F-statistic:  8.42 on 1 and 134 DF,  p-value: 0.004339
PL_Cdiam_lm1_r <- lmer(corolla_d_c ~ Treatment + AG_biom_c + (1|Recipient), data = BB_Fplants)
summary(PL_Cdiam_lm1_r)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: corolla_d_c ~ Treatment + AG_biom_c + (1 | Recipient)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 352.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2641 -0.6294  0.1172  0.5713  2.0320 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  3.518   1.876   
##  Residual              18.105   4.255   
## Number of obs: 60, groups:  Recipient, 19
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)  
## (Intercept)  0.30603    0.73358 11.37664   0.417    0.684  
## Treatment1  -1.36598    0.60714 48.55912  -2.250    0.029 *
## AG_biom_c    0.02582    0.03226 55.88610   0.801    0.427  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr) Trtmn1
## Treatment1 -0.128       
## AG_biom_c  -0.021  0.298
r.squaredGLMM(PL_Cdiam_lm1_r)
##            R2m      R2c
## [1,] 0.1036841 0.249517
ranef(PL_Cdiam_lm1_r) 
## $Recipient
##        (Intercept)
## BB_017   0.4899511
## BB_020   0.3822618
## BB_024   0.4650694
## BB_032   1.5599739
## BB_049  -0.1823453
## BB_051   0.8322155
## BB_059  -0.4402279
## BB_061  -1.9743637
## BB_077   0.7425428
## BB_079  -0.3764723
## BB_085   2.0179797
## BB_102   0.1653581
## BB_118   0.4327379
## BB_137  -0.4568437
## BB_143  -0.2640011
## BB_152  -0.9892041
## BB_161   1.0890920
## BB_164  -1.5180532
## BB_185  -1.9756709
## 
## with conditional variances for "Recipient"
#Control for biomass
PL_Cdiam_lm1_mv <- lm(corolla_d_c ~ Treatment + AG_biom_c, data = BB_Fplants)
summary(PL_Cdiam_lm1_mv)
## 
## Call:
## lm(formula = corolla_d_c ~ Treatment + AG_biom_c, data = BB_Fplants)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.0247  -3.3846   0.4105   3.1768  10.7140 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  0.08402    0.60238   0.139   0.8896  
## Treatment1  -1.19970    0.63208  -1.898   0.0628 .
## AG_biom_c    0.02028    0.03264   0.621   0.5368  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.601 on 57 degrees of freedom
##   (165 observations deleted due to missingness)
## Multiple R-squared:  0.08329,    Adjusted R-squared:  0.05112 
## F-statistic: 2.589 on 2 and 57 DF,  p-value: 0.08387
PL_Cdiam_lm1_mvr <- lmer(corolla_d_c ~ Treatment + AG_biom_c + (1|Recipient), data = BB_Fplants)
summary(PL_Cdiam_lm1_mvr)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: corolla_d_c ~ Treatment + AG_biom_c + (1 | Recipient)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 352.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2641 -0.6294  0.1172  0.5713  2.0320 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  3.518   1.876   
##  Residual              18.105   4.255   
## Number of obs: 60, groups:  Recipient, 19
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)  
## (Intercept)  0.30603    0.73358 11.37664   0.417    0.684  
## Treatment1  -1.36598    0.60714 48.55912  -2.250    0.029 *
## AG_biom_c    0.02582    0.03226 55.88610   0.801    0.427  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr) Trtmn1
## Treatment1 -0.128       
## AG_biom_c  -0.021  0.298
r.squaredGLMM(PL_Cdiam_lm1_mvr)
##            R2m      R2c
## [1,] 0.1036841 0.249517
ranef(PL_Cdiam_lm1_mvr) #Both Location or Block result in singular model
## $Recipient
##        (Intercept)
## BB_017   0.4899511
## BB_020   0.3822618
## BB_024   0.4650694
## BB_032   1.5599739
## BB_049  -0.1823453
## BB_051   0.8322155
## BB_059  -0.4402279
## BB_061  -1.9743637
## BB_077   0.7425428
## BB_079  -0.3764723
## BB_085   2.0179797
## BB_102   0.1653581
## BB_118   0.4327379
## BB_137  -0.4568437
## BB_143  -0.2640011
## BB_152  -0.9892041
## BB_161   1.0890920
## BB_164  -1.5180532
## BB_185  -1.9756709
## 
## with conditional variances for "Recipient"

Aboveground Biomass

#Biomass *
PL_AGbio_lm1 <- lm(AG_biom_c ~ Treatment, data = BB_Fplants)
summary(PL_AGbio_lm1)
## 
## Call:
## lm(formula = AG_biom_c ~ Treatment, data = BB_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -24.288 -12.594  -6.110   7.937  70.382 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)   -1.789      1.995  -0.897    0.372  
## Treatment1    -3.784      1.995  -1.896    0.061 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 19.36 on 93 degrees of freedom
##   (130 observations deleted due to missingness)
## Multiple R-squared:  0.03722,    Adjusted R-squared:  0.02687 
## F-statistic: 3.596 on 1 and 93 DF,  p-value: 0.06103
PL_AGbio_lm1_r <- lmer(AG_biom_c ~ Treatment + (1|Recipient), data = BB_Fplants)
## boundary (singular) fit: see help('isSingular')
summary(PL_AGbio_lm1_r)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: AG_biom_c ~ Treatment + (1 | Recipient)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 824.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.2544 -0.6504 -0.3156  0.4099  3.6350 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)   0.0     0.00   
##  Residual              374.9    19.36   
## Number of obs: 95, groups:  Recipient, 21
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)  
## (Intercept)   -1.789      1.995 93.000  -0.897    0.372  
## Treatment1    -3.784      1.995 93.000  -1.896    0.061 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.095
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
r.squaredGLMM(PL_Cdiam_lm1_r)
##            R2m      R2c
## [1,] 0.1036841 0.249517
ranef(PL_Cdiam_lm1_r) #Both Location or Block result in singular model
## $Recipient
##        (Intercept)
## BB_017   0.4899511
## BB_020   0.3822618
## BB_024   0.4650694
## BB_032   1.5599739
## BB_049  -0.1823453
## BB_051   0.8322155
## BB_059  -0.4402279
## BB_061  -1.9743637
## BB_077   0.7425428
## BB_079  -0.3764723
## BB_085   2.0179797
## BB_102   0.1653581
## BB_118   0.4327379
## BB_137  -0.4568437
## BB_143  -0.2640011
## BB_152  -0.9892041
## BB_161   1.0890920
## BB_164  -1.5180532
## BB_185  -1.9756709
## 
## with conditional variances for "Recipient"
##Multivariate Models

#Use Fitness plants only (BB_Fplants)! Fewer NAs and 0s to deal with - more parsimonious data set

# Doesn't always make sense to control for additional variables - trait specific models
# Control for Block & Genotype as random effects - But Block may be redundant with watering effect! Location, however, explains very little variance in traits and results in singular MMs. Include Block for now, appears more important for explaining variance in ambient locations...

Notes:

Best/simplest approach for these analyses may be to focus on Bivariate models including random effects of Recipient and Block/Location. Multivariate models may help explain trait variance, but we can discuss interactions and correlations among traits separately (e.g., watering increased plant size and corolla area, and these two traits may be linked/ are both indicators of resource acquisition…)

Correlations controlling for watering: AG_biomass ~ corolla_diam + Treatment…

To-Do: - Create MMs for single main effect of treatment - Use standardized Trait variables (compare both models) - Model diagnostics - Explore trait correlations that may account for some trends in watered plants

#Visualizations

# Simple Reaction Norms
  1. Is the strength and direction of plasticity in functional traits consistent (a) among populations and (b) within populations among genotypes?

I.e: (a) At the population level, are plastic changes in traits with water addition consistent in direction and in magnitude? (b) Do plastic changes with watering among genotypes within populations mirror one another?

Note: Use standardized trait values, but note that comparisons among populations (at least in magnitude) are fraught due to local climatic differences and differences in the amount of additional soil moisture actually experienced by watered plants relative to ambient plants at each site.

Analysis: - (a) Extract standardized regression coefficients from the bivariate models above (controlling for random effects) and compare these among populations - (b) Document among-genotype variation in plasticity (all traits?) within populations by comparing variance measures (HOW DO??) — G*E interactions? — Variance components from random effect of genotype?

Some questions: - How many watered v.s. non-watered fitness plants (observations) are there? - On average, how many fitness plants are there to each Recipient ID (in each block)? - What kind of trends in quantitative/numeric trait variables can you identify? - How do trait values differ across locations and between experiments?



John’s Models

Some commented-out lines copied from his knit Rmds

Bodega

Main Effects

# FLOWERING DURATION
#BB_final_full$log_duration <- log(BB_final_full$fl_duration+1)
#BB_duration_Model = lmer(log_duration ~ watered + (1|Block) + (1|Recipient), data = BB_final_full, REML = T)

#*Best* simple linear model -log and sqrt both work?? sqrt+1 results in nice residuals, better adj R2
PL_Fdur_lm0 <- lm(fl_duration ~ Treatment, data = BB_allplants)
summary(PL_Fdur_lm0)
## 
## Call:
## lm(formula = fl_duration ~ Treatment, data = BB_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -17.702 -11.685  -3.702   8.315  50.315 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  15.6939     0.7443  21.086  < 2e-16 ***
## Treatment1   -3.0086     0.7443  -4.042 6.66e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.89 on 316 degrees of freedom
##   (522 observations deleted due to missingness)
## Multiple R-squared:  0.04917,    Adjusted R-squared:  0.04616 
## F-statistic: 16.34 on 1 and 316 DF,  p-value: 6.656e-05
plot(PL_Fdur_lm0)

hist(PL_Fdur_lm0$residuals)

##UNSURE which transformation is best!

#John's model equivalent
PL_Fdur_lm1 <- lmer(log(fl_duration+1) ~ Treatment + (1|Recipient) + (1|Block), data = BB_allplants, REML = T)
summary(PL_Fdur_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(fl_duration + 1) ~ Treatment + (1 | Recipient) + (1 | Block)
##    Data: BB_allplants
## 
## REML criterion at convergence: 939.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.8256 -1.1051  0.1926  0.7749  1.7273 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.00535  0.07314 
##  Block     (Intercept) 0.03206  0.17906 
##  Residual              1.09119  1.04460 
## Number of obs: 318, groups:  Recipient, 21; Block, 4
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)   
## (Intercept)   2.3611     0.1210  1.7219  19.509  0.00506 **
## Treatment1   -0.1916     0.1200  1.6550  -1.596  0.27616   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.425
r.squaredGLMM(PL_Fdur_lm1)
##             R2m        R2c
## [1,] 0.02983624 0.06199636
#ranef(PL_Fdur_lm1)


#Better model
PL_Fdur_lm2 <- lmer(fl_duration ~ Treatment + (1|Location), data = BB_allplants)
summary(PL_Fdur_lm2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: fl_duration ~ Treatment + (1 | Location)
##    Data: BB_allplants
## 
## REML criterion at convergence: 2514.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.8393 -0.7100 -0.2060  0.5261  3.8505 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Location (Intercept)  22.68    4.762  
##  Residual             145.45   12.060  
## Number of obs: 318, groups:  Location, 65
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   15.177      1.046 37.075  14.505   <2e-16 ***
## Treatment1    -2.746      1.046 37.075  -2.625   0.0125 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.419
r.squaredGLMM(PL_Fdur_lm2)
##            R2m       R2c
## [1,] 0.0407051 0.1701059
ranef(PL_Fdur_lm2)
## $Location
##      (Intercept)
## 2     4.13165864
## 4    -0.97051062
## 5    -0.77478678
## 8     4.11188563
## 9     2.09347746
## 10   -2.00422106
## 15    1.96522054
## 20    3.41674719
## 26   -0.05709577
## 30    7.11907454
## 34    3.92911718
## 39   -1.83710687
## 40   -5.50810032
## 44   -0.86750360
## 46   -0.22134211
## 47   -1.90010555
## 50   -1.96411853
## 52    3.12987926
## 53   -1.71603605
## 59    0.19441220
## 60   -0.16278252
## 62    2.70248439
## 64    0.41058212
## 67    1.15587079
## 70   -0.21959796
## 73   -2.00422106
## 76   -1.29106948
## 77   -3.64305102
## 79   -1.17221088
## 80.5  5.25845574
## 83   -0.66855477
## 84   -3.64305102
## 85    2.62463751
## 86    4.92401545
## 87   -2.12307965
## 88   -3.64305102
## 90   -1.98736195
## 99    4.65186034
## 100  -4.01252475
## 107  -2.53611402
## 109  -1.54196172
## 110  -1.60037824
## 112  -3.91406492
## 113  -2.71737264
## 114  -3.81475972
## 115  -3.64305102
## 119  -1.54196172
## 120   5.18062243
## 122   0.79470411
## 125   0.16160218
## 129  -1.12590582
## 130   0.94673670
## 132  -1.54196172
## 134   2.77228019
## 136  -3.00565897
## 140  -4.67621585
## 141  -2.25130887
## 143   6.31684869
## 144   0.67776245
## 146   3.14056753
## 147   3.17924518
## 150   2.28780908
## 151  -0.34020071
## 155   0.02646014
## 160  -0.66161838
## 
## with conditional variances for "Location"
plot(PL_Fdur_lm2)

#Log transofrmation seems more appropriate here...? Better R2c
#Location results in singular model but block does not
##FIRST FLOWERING DATE
#BB_FFD_Model = lmer(FFD_DOY ~ watered + (1|Block) + (1|Recipient), data = BB_final_full, REML = T)

#best lm 
PL_FFD_lm0 <- lm(FFD_z ~ Treatment, data = BB_allplants)
summary(PL_FFD_lm0)
## 
## Call:
## lm(formula = FFD_z ~ Treatment, data = BB_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2915 -0.5976  0.0800  0.7142  4.2005 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.006587   0.057821  -0.114    0.909
## Treatment1   0.027563   0.057821   0.477    0.634
## 
## Residual standard error: 1.001 on 316 degrees of freedom
##   (522 observations deleted due to missingness)
## Multiple R-squared:  0.0007186,  Adjusted R-squared:  -0.002444 
## F-statistic: 0.2272 on 1 and 316 DF,  p-value: 0.6339
plot(PL_FFD_lm0)

hist(PL_FFD_lm0$residuals)

#John's model equivalent 
PL_FFD_lm1 <- lmer(yday(FFD) ~ Treatment + (1|Recipient) + (1|Block), data = BB_allplants)
## boundary (singular) fit: see help('isSingular')
summary(PL_FFD_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: yday(FFD) ~ Treatment + (1 | Recipient) + (1 | Block)
##    Data: BB_allplants
## 
## REML criterion at convergence: 2452.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6909 -0.6384 -0.0498  0.4373  4.3709 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  18.76    4.332  
##  Block     (Intercept)   0.00    0.000  
##  Residual              122.89   11.086  
## Number of obs: 318, groups:  Recipient, 21; Block, 4
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  83.32860    1.14944  19.49311  72.495   <2e-16 ***
## Treatment1   -0.06952    0.66507 312.12445  -0.105    0.917    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.139
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
r.squaredGLMM(PL_FFD_lm1)
##               R2m       R2c
## [1,] 3.226998e-05 0.1324817
ranef(PL_FFD_lm1) #Model is singular when using Block instead of Location
## $Recipient
##        (Intercept)
## BB_017  -6.3388025
## BB_020  -2.0811881
## BB_024  -3.7074741
## BB_032   6.1636658
## BB_049  -1.9748934
## BB_051  -2.5461178
## BB_059   2.5716485
## BB_061   4.0687139
## BB_077   0.1478030
## BB_079   0.1911948
## BB_085  -5.1821042
## BB_102  -2.7303583
## BB_105  -1.1700497
## BB_118  -1.4604022
## BB_137  -0.6482969
## BB_143   1.0148859
## BB_152  -1.7945927
## BB_161   7.4568323
## BB_164   3.8776317
## BB_185   0.2492218
## BB_187   3.8926822
## 
## $Block
##   (Intercept)
## 1           0
## 2           0
## 3           0
## W           0
## 
## with conditional variances for "Recipient" "Block"
#Better model - remove Recipient? Still NS, same results
PL_FFD_lm2 <- lmer(yday(FFD) ~ Treatment + (1|Recipient) + (1|Location), data = BB_allplants)
summary(PL_FFD_lm2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: yday(FFD) ~ Treatment + (1 | Recipient) + (1 | Location)
##    Data: BB_allplants
## 
## REML criterion at convergence: 2415.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.0326 -0.6276 -0.1231  0.5090  4.0075 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Location  (Intercept) 51.645   7.186   
##  Recipient (Intercept)  5.187   2.278   
##  Residual              90.963   9.537   
## Number of obs: 318, groups:  Location, 65; Recipient, 21
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   84.678      1.355 33.416  62.509   <2e-16 ***
## Treatment1    -0.848      1.262 38.615  -0.672    0.506    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.462
r.squaredGLMM(PL_FFD_lm2)
##              R2m       R2c
## [1,] 0.004580967 0.3873525
ranef(PL_FFD_lm2)
## $Location
##       (Intercept)
## 2     -3.83327034
## 4     -1.23138885
## 5      1.59919320
## 8     -0.16702018
## 9     -1.56117894
## 10     3.60982642
## 15     9.64240525
## 20    -0.02529969
## 26     2.94145706
## 30     1.59661731
## 34    -3.37831371
## 39     2.01303340
## 40     7.33601403
## 44     2.58571417
## 46    -7.03118180
## 47    -3.39617312
## 50    -4.90643401
## 52    -1.59074347
## 53     2.85402807
## 59    -2.97387544
## 60    -5.48498928
## 62    -5.00954654
## 64    -3.76273004
## 67     4.63568332
## 70    13.49842018
## 73     4.66683791
## 76     1.44782698
## 77     9.03998802
## 79     2.05330323
## 80.5   2.28133220
## 83     3.88440216
## 84     5.18571737
## 85     2.33744616
## 86   -12.84165458
## 87     1.98596278
## 88     0.32905302
## 90     2.54058164
## 99   -11.66449390
## 100   -0.02512620
## 107   -2.30939702
## 109    3.17845634
## 110    4.17762700
## 112   10.60866185
## 113    3.45661703
## 114    9.96120712
## 115   -1.52030617
## 119   12.36840662
## 120  -10.68870378
## 122   -6.15137793
## 125    2.39613114
## 129   -4.69689475
## 130   -6.53464697
## 132   -4.33013498
## 134  -11.08874917
## 136    3.96472176
## 140    2.54972529
## 141    2.70504949
## 143   -4.49234725
## 144   -6.16268930
## 146   -8.11111709
## 147   -2.45162161
## 150    1.99901305
## 151   -0.75482712
## 155    1.08520309
## 160   -8.33943043
## 
## $Recipient
##        (Intercept)
## BB_017 -2.35225741
## BB_020 -0.36810552
## BB_024 -0.60675140
## BB_032  0.82255847
## BB_049 -1.27021717
## BB_051 -1.41044180
## BB_059  1.10693422
## BB_061  1.54421471
## BB_077  0.91620646
## BB_079 -0.87312513
## BB_085 -1.15279262
## BB_102 -0.66164285
## BB_105  0.30841923
## BB_118 -1.83073717
## BB_137  0.43506374
## BB_143  1.01685156
## BB_152  1.02999964
## BB_161  1.94711431
## BB_164  1.36937805
## BB_185  0.08963305
## BB_187 -0.06030239
## 
## with conditional variances for "Location" "Recipient"
# COROLLA DIAMETER
#BB_diameter_Model = lmer(corolla_diam_mm ~ watered + (1|Block) + (1|Recipient), data = BB_final, REML = T)

#best lm
PL_Cd_lm0 <- lm(corolla_diam_mm ~ Treatment, data = BB_Fplants)
summary(PL_Cd_lm0)
## 
## Call:
## lm(formula = corolla_diam_mm ~ Treatment, data = BB_Fplants)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -10.3677  -3.3574   0.1757   3.3192  12.5733 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  23.0273     0.4186  55.011  < 2e-16 ***
## Treatment1   -1.2147     0.4186  -2.902  0.00434 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.687 on 134 degrees of freedom
##   (89 observations deleted due to missingness)
## Multiple R-squared:  0.05912,    Adjusted R-squared:  0.0521 
## F-statistic:  8.42 on 1 and 134 DF,  p-value: 0.004339
plot(PL_Cd_lm0)

hist(PL_Cd_lm0$residuals)

#John's equivalent model
PL_Cdiam_lm1 <- lmer(corolla_diam_mm ~ Treatment + (1|Block) + (1|Recipient), data = BB_Fplants)
summary(PL_Cdiam_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: corolla_diam_mm ~ Treatment + (1 | Block) + (1 | Recipient)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 797.9
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.53414 -0.67403  0.05407  0.69534  2.22526 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  2.433   1.560   
##  Block     (Intercept)  2.424   1.557   
##  Residual              18.779   4.333   
## Number of obs: 136, groups:  Recipient, 21; Block, 4
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)   
## (Intercept)  22.9315     1.0408  2.1722  22.032  0.00135 **
## Treatment1   -1.3950     0.9835  1.7579  -1.418  0.30744   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.437
r.squaredGLMM(PL_Cdiam_lm1)
##             R2m       R2c
## [1,] 0.07103367 0.2619411
#ranef(PL_Cdiam_lm1) #Both Location or Block result in singular model...
#Block explains variation in corolla diameter better than treatment or Recipient!


#Better model? Same results
PL_Cdiam_lm2 <- lmer(corolla_diam_mm ~ Treatment + (1|Location) + (1|Recipient), data = BB_Fplants)
summary(PL_Cdiam_lm2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: corolla_diam_mm ~ Treatment + (1 | Location) + (1 | Recipient)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 801.2
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.28525 -0.62951  0.03972  0.63856  2.37703 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Location  (Intercept)  1.739   1.319   
##  Recipient (Intercept)  1.832   1.353   
##  Residual              18.659   4.320   
## Number of obs: 136, groups:  Location, 60; Recipient, 21
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  22.9616     0.5439 19.3398  42.217  < 2e-16 ***
## Treatment1   -1.3350     0.4548 23.9872  -2.935  0.00723 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.304
r.squaredGLMM(PL_Cdiam_lm2)
##             R2m       R2c
## [1,] 0.06929819 0.2188034
#ranef(PL_Cdiam_lm2)
#ABOVEGROUND BIOMASS
#BB_final$log_biomass <- log(BB_final$AG_biomass_mg)
#BB_biomass_Model = lmer(log_biomass ~ watered + (1|Block) + (1|Recipient), data = BB_final, REML = T)

#Best lm
PL_AG_lm0 <- lm(AG_biomass_mg ~ Treatment, data = BB_Fplants)
summary(PL_AG_lm0)
## 
## Call:
## lm(formula = AG_biomass_mg ~ Treatment, data = BB_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -24.288 -12.594  -6.110   7.937  70.382 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   21.784      1.995  10.916   <2e-16 ***
## Treatment1    -3.784      1.995  -1.896    0.061 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 19.36 on 93 degrees of freedom
##   (130 observations deleted due to missingness)
## Multiple R-squared:  0.03722,    Adjusted R-squared:  0.02687 
## F-statistic: 3.596 on 1 and 93 DF,  p-value: 0.06103
plot(PL_AG_lm0)

hist(PL_AG_lm0$residuals)

#Transformation unnecessary? Better R2, marginally NS


#John Equivalent Model
PL_AGbio_lm1 <- lmer(log(AG_biomass_mg) ~ Treatment + (1|Location) + (1|Recipient), data = BB_Fplants)
## boundary (singular) fit: see help('isSingular')
summary(PL_AGbio_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(AG_biomass_mg) ~ Treatment + (1 | Location) + (1 | Recipient)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 248.3
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.47160 -0.62149  0.06617  0.59026  1.92437 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Location  (Intercept) 0.1508   0.3884  
##  Recipient (Intercept) 0.0000   0.0000  
##  Residual              0.6431   0.8019  
## Number of obs: 95, groups:  Location, 47; Recipient, 21
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  2.67968    0.10738 29.48622  24.955   <2e-16 ***
## Treatment1  -0.06436    0.10738 29.48622  -0.599    0.554    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.244
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
r.squaredGLMM(PL_Cdiam_lm1)
##             R2m       R2c
## [1,] 0.07103367 0.2619411
ranef(PL_Cdiam_lm1) #Both Location or Block result in singular model
## $Recipient
##        (Intercept)
## BB_017 -0.18022322
## BB_020  0.01952809
## BB_024 -0.25812589
## BB_032  0.22634043
## BB_049 -0.34396967
## BB_051  1.24023209
## BB_059  0.13983849
## BB_061 -1.97150244
## BB_077  0.41111741
## BB_079  1.35547499
## BB_085  0.64592842
## BB_102  1.29339560
## BB_105 -0.35375886
## BB_118  0.24879740
## BB_137  0.58507656
## BB_143 -0.44847727
## BB_152 -1.18241408
## BB_161  2.19212642
## BB_164 -0.91160214
## BB_185 -1.59430199
## BB_187 -1.11348032
## 
## $Block
##     (Intercept)
## 1  1.580073e+00
## 2 -8.658975e-01
## 3 -7.141753e-01
## W -8.090670e-14
## 
## with conditional variances for "Recipient" "Block"
#Better model? #similar results as lm
PL_AGbio_lm2 <- lmer(AG_biomass_mg ~ Treatment + (1|Location), data = BB_Fplants)
summary(PL_AGbio_lm2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: AG_biomass_mg ~ Treatment + (1 | Location)
##    Data: BB_Fplants
## 
## REML criterion at convergence: 824
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.1574 -0.6053 -0.2880  0.2975  3.5835 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Location (Intercept)  15.99    3.999  
##  Residual             359.46   18.960  
## Number of obs: 95, groups:  Location, 47
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   21.724      2.083 30.710  10.428  1.3e-11 ***
## Treatment1    -3.679      2.083 30.710  -1.766   0.0873 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.138
r.squaredGLMM(PL_Cdiam_lm2)
##             R2m       R2c
## [1,] 0.06929819 0.2188034
ranef(PL_Cdiam_lm2)
## $Location
##      (Intercept)
## 2     1.19838277
## 4     0.79035602
## 5     0.02896805
## 8     0.80353050
## 9     0.30937637
## 10   -0.29820937
## 20    0.17022780
## 26   -0.31938080
## 30    0.50341349
## 34    0.82215204
## 39    0.69464557
## 40   -0.05286850
## 44    0.15392778
## 46    0.00597208
## 47   -0.64341118
## 50    0.43066476
## 52    0.54585612
## 53    0.23698897
## 59   -0.27438370
## 60    0.16921935
## 62   -0.64769414
## 64   -0.02947460
## 67   -0.09658465
## 70   -0.81424854
## 73   -0.49651820
## 76    0.44637536
## 77    0.21478981
## 79   -0.49954694
## 80.5  0.58423475
## 83   -0.63099051
## 84   -0.62240612
## 85    0.82187718
## 86    0.06736266
## 87   -0.06240165
## 88   -0.25663933
## 90   -0.56308617
## 100  -0.52678934
## 110   0.24278958
## 112  -0.16651833
## 113  -0.47823729
## 114  -0.22244929
## 115  -0.15501731
## 120  -1.07043748
## 122  -1.27342225
## 125  -0.01636197
## 129   0.08818279
## 130  -0.33855796
## 132  -0.29466771
## 134  -0.14512267
## 136  -0.66177357
## 140   0.40058366
## 141  -0.21796364
## 143   0.40553462
## 144   0.12760664
## 146   0.25228767
## 147  -0.25242739
## 150   0.38362901
## 151   0.24724707
## 155   0.32995477
## 160   0.65145338
## 
## $Recipient
##        (Intercept)
## BB_017 -0.10687380
## BB_020  0.13401863
## BB_024 -0.04867275
## BB_032  0.05648702
## BB_049 -0.25709783
## BB_051  0.99093569
## BB_059 -0.10039915
## BB_061 -1.61074333
## BB_077  0.16336372
## BB_079  0.80810748
## BB_085  0.55439625
## BB_102  0.95935836
## BB_105 -0.26815302
## BB_118  0.46193623
## BB_137  0.57518627
## BB_143 -0.42551305
## BB_152 -0.99683652
## BB_161  1.70122406
## BB_164 -0.74492948
## BB_185 -0.94752508
## BB_187 -0.89826970
## 
## with conditional variances for "Location" "Recipient"
plot(PL_AGbio_lm2)

# FECUNDITY
#BB_final2$log_seedprod <- log(BB_final2$total_est_seed_production)
#BB_seed_Model = lmer(log_seedprod ~ watered + (1|Block) + (1|Recipient), data = BB_final2, REML = T)

#lm
#filtered to individuals that produced seed
PL_fec_lm0 <- lm(log(total_est_seed_production) ~ Treatment, data = filter(BB_Fplants, surv_to_seedprod == 1))
summary(PL_fec_lm0)
## 
## Call:
## lm(formula = log(total_est_seed_production) ~ Treatment, data = filter(BB_Fplants, 
##     surv_to_seedprod == 1))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.8929 -0.5066 -0.0693  0.5639  3.5329 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.6742     0.1138  14.713   <2e-16 ***
## Treatment1   -0.2186     0.1138  -1.921   0.0583 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.024 on 79 degrees of freedom
## Multiple R-squared:  0.04464,    Adjusted R-squared:  0.03254 
## F-statistic: 3.691 on 1 and 79 DF,  p-value: 0.05831
plot(PL_fec_lm0)

hist(PL_fec_lm0$residuals)

#John's equivalent model
#Excludes plants that didn't survive to produce seeds!!
PL_fec_lm1 <- lmer(log(total_est_seed_production) ~ Treatment + (1|Recipient) + (1|Block), data = filter(BB_Fplants, surv_to_seedprod == 1))
summary(PL_fec_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(total_est_seed_production) ~ Treatment + (1 | Recipient) +  
##     (1 | Block)
##    Data: filter(BB_Fplants, surv_to_seedprod == 1)
## 
## REML criterion at convergence: 232.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.9203 -0.6066 -0.0445  0.6297  3.4282 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.187807 0.43337 
##  Block     (Intercept) 0.009578 0.09787 
##  Residual              0.858017 0.92629 
## Number of obs: 81, groups:  Recipient, 20; Block, 4
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)  
## (Intercept)   1.6233     0.1560  1.1551  10.404    0.044 *
## Treatment1   -0.2174     0.1250  0.4251  -1.739    0.511  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.072
r.squaredGLMM(PL_fec_lm1)
##             R2m       R2c
## [1,] 0.04336976 0.2222824
#! N = 80 individuals! compared to 225

#Better model?
PL_fec_lm2 <- lmer(log(total_est_seed_production) ~ Treatment + (1|Recipient) + (1|Location), data = filter(BB_Fplants, surv_to_seedprod == 1))
summary(PL_fec_lm2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(total_est_seed_production) ~ Treatment + (1 | Recipient) +  
##     (1 | Location)
##    Data: filter(BB_Fplants, surv_to_seedprod == 1)
## 
## REML criterion at convergence: 231.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.8553 -0.5988  0.0286  0.5352  3.4593 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Location  (Intercept) 0.1153   0.3396  
##  Recipient (Intercept) 0.1747   0.4180  
##  Residual              0.7719   0.8786  
## Number of obs: 81, groups:  Location, 35; Recipient, 20
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   1.6158     0.1543 19.4928  10.474  1.9e-09 ***
## Treatment1   -0.2135     0.1259 20.3054  -1.696    0.105    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.090
r.squaredGLMM(PL_fec_lm2)
##             R2m       R2c
## [1,] 0.04162432 0.3033846
##Use GLM?





## SEED COUNT - not analyzed
#lm

GxE Effects

Based on John’s models - (minor improvements made)

#FFD
GxE_FFD_lm0 <- lm(yday(FFD) ~ Recipient*Treatment + Location, data = filter(BB_allplants, Recipient != "BB_161"))
summary(GxE_FFD_lm0)
## 
## Call:
## lm(formula = yday(FFD) ~ Recipient * Treatment + Location, data = filter(BB_allplants, 
##     Recipient != "BB_161"))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -28.032  -6.467  -0.690   4.817  42.180 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             87.22535    1.50938  57.789  < 2e-16 ***
## Recipient1              -9.09077    2.37896  -3.821 0.000165 ***
## Recipient2              -2.32999    2.40914  -0.967 0.334347    
## Recipient3              -4.77895    2.92224  -1.635 0.103150    
## Recipient4               5.77052    3.16597   1.823 0.069472 .  
## Recipient5              -3.42764    2.34590  -1.461 0.145158    
## Recipient6              -3.20894    2.93239  -1.094 0.274807    
## Recipient7               5.62413    2.83284   1.985 0.048131 *  
## Recipient8               8.78497    3.39314   2.589 0.010152 *  
## Recipient9               3.98402    3.19856   1.246 0.214017    
## Recipient10              0.97625    3.43385   0.284 0.776400    
## Recipient11             -5.11864    2.91841  -1.754 0.080593 .  
## Recipient12             -2.99649    2.27542  -1.317 0.189003    
## Recipient13             -0.77401    3.33822  -0.232 0.816822    
## Recipient14             -2.27691    2.39086  -0.952 0.341786    
## Recipient15             -1.10816    2.86246  -0.387 0.698963    
## Recipient16              0.12453    2.79350   0.045 0.964476    
## Recipient17             -2.03517    2.89688  -0.703 0.482956    
## Recipient18              7.67621    3.81514   2.012 0.045220 *  
## Recipient19             -1.02998    2.89744  -0.355 0.722511    
## Treatment1              -1.30049    0.69598  -1.869 0.062780 .  
## Location                -0.03942    0.01472  -2.678 0.007860 ** 
## Recipient1:Treatment1    5.02344    2.37557   2.115 0.035389 *  
## Recipient2:Treatment1    1.61660    2.41552   0.669 0.503911    
## Recipient3:Treatment1    4.78964    2.92676   1.636 0.102914    
## Recipient4:Treatment1    8.86384    3.18526   2.783 0.005774 ** 
## Recipient5:Treatment1    2.38927    2.34919   1.017 0.310046    
## Recipient6:Treatment1   -0.45880    2.93977  -0.156 0.876099    
## Recipient7:Treatment1   -3.61472    2.81730  -1.283 0.200589    
## Recipient8:Treatment1   -4.83286    3.39361  -1.424 0.155584    
## Recipient9:Treatment1  -12.88624    3.20604  -4.019  7.6e-05 ***
## Recipient10:Treatment1  -0.33749    3.41539  -0.099 0.921359    
## Recipient11:Treatment1  -4.64036    2.90738  -1.596 0.111659    
## Recipient12:Treatment1  -0.82911    2.26674  -0.366 0.714824    
## Recipient13:Treatment1   0.29426    3.31801   0.089 0.929399    
## Recipient14:Treatment1   5.18895    2.39016   2.171 0.030815 *  
## Recipient15:Treatment1   0.31040    2.86246   0.108 0.913730    
## Recipient16:Treatment1  -0.43000    2.73910  -0.157 0.875373    
## Recipient17:Treatment1  -0.49570    2.86288  -0.173 0.862666    
## Recipient18:Treatment1  -2.34550    3.81842  -0.614 0.539567    
## Recipient19:Treatment1   0.12997    2.88240   0.045 0.964069    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.52 on 267 degrees of freedom
##   (492 observations deleted due to missingness)
## Multiple R-squared:  0.2817, Adjusted R-squared:  0.1741 
## F-statistic: 2.618 on 40 and 267 DF,  p-value: 2.738e-06
plot(GxE_FFD_lm0)

hist(GxE_FFD_lm0$residuals)

Anova(GxE_FFD_lm0, type = 3)
## Anova Table (Type III tests)
## 
## Response: yday(FFD)
##                     Sum Sq  Df   F value    Pr(>F)    
## (Intercept)         369363   1 3339.5358 < 2.2e-16 ***
## Recipient             5152  19    2.4517 0.0008646 ***
## Treatment              386   1    3.4915 0.0627795 .  
## Location               793   1    7.1729 0.0078602 ** 
## Recipient:Treatment   4676  19    2.2252 0.0028349 ** 
## Residuals            29531 267                        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
GxE_FFD_lm_rs <- lm(yday(FFD) ~ Recipient*Treatment + Location, data = BB_allplants)


#Flowering Duration
GxE_Fdur_lm0 <- lm(fl_duration ~ Recipient*Treatment + Location, data = filter(BB_allplants, Recipient != "BB_161"))
summary(GxE_Fdur_lm0)
## 
## Call:
## lm(formula = fl_duration ~ Recipient * Treatment + Location, 
##     data = filter(BB_allplants, Recipient != "BB_161"))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -31.264  -8.390  -1.288   6.941  42.044 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            17.99930    1.82339   9.871  < 2e-16 ***
## Recipient1             10.46511    2.87387   3.641 0.000326 ***
## Recipient2              1.22298    2.91033   0.420 0.674662    
## Recipient3              0.17556    3.53018   0.050 0.960374    
## Recipient4             -4.49749    3.82461  -1.176 0.240669    
## Recipient5             -3.39107    2.83393  -1.197 0.232525    
## Recipient6              0.56485    3.54244   0.159 0.873433    
## Recipient7              4.80898    3.42218   1.405 0.161113    
## Recipient8             -2.14524    4.09905  -0.523 0.601163    
## Recipient9             -2.13629    3.86399  -0.553 0.580815    
## Recipient10             5.63734    4.14822   1.359 0.175300    
## Recipient11            -2.42216    3.52555  -0.687 0.492660    
## Recipient12             4.04712    2.74880   1.472 0.142111    
## Recipient13             0.44001    4.03270   0.109 0.913197    
## Recipient14            -1.41923    2.88825  -0.491 0.623560    
## Recipient15            -1.03614    3.45796  -0.300 0.764686    
## Recipient16            -6.53468    3.37465  -1.936 0.053874 .  
## Recipient17            -0.57548    3.49954  -0.164 0.869506    
## Recipient18            -1.31903    4.60883  -0.286 0.774950    
## Recipient19             2.78854    3.50022   0.797 0.426348    
## Treatment1             -2.98569    0.84078  -3.551 0.000453 ***
## Location               -0.03205    0.01778  -1.803 0.072589 .  
## Recipient1:Treatment1  -4.66012    2.86978  -1.624 0.105585    
## Recipient2:Treatment1  -5.48812    2.91804  -1.881 0.061093 .  
## Recipient3:Treatment1  -6.56504    3.53564  -1.857 0.064438 .  
## Recipient4:Treatment1  -5.22394    3.84792  -1.358 0.175736    
## Recipient5:Treatment1   1.47452    2.83791   0.520 0.603788    
## Recipient6:Treatment1   2.46372    3.55136   0.694 0.488449    
## Recipient7:Treatment1  -1.96776    3.40340  -0.578 0.563633    
## Recipient8:Treatment1   4.07510    4.09961   0.994 0.321112    
## Recipient9:Treatment1   5.13426    3.87301   1.326 0.186089    
## Recipient10:Treatment1 -1.80030    4.12592  -0.436 0.662943    
## Recipient11:Treatment1  8.42851    3.51223   2.400 0.017091 *  
## Recipient12:Treatment1  1.92567    2.73831   0.703 0.482522    
## Recipient13:Treatment1 -1.40791    4.00828  -0.351 0.725677    
## Recipient14:Treatment1 -4.13519    2.88741  -1.432 0.153271    
## Recipient15:Treatment1  2.00945    3.45796   0.581 0.561657    
## Recipient16:Treatment1  2.67104    3.30893   0.807 0.420257    
## Recipient17:Treatment1  1.77178    3.45847   0.512 0.608863    
## Recipient18:Treatment1  2.78163    4.61280   0.603 0.547004    
## Recipient19:Treatment1 -1.76890    3.48205  -0.508 0.611869    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.7 on 267 degrees of freedom
##   (492 observations deleted due to missingness)
## Multiple R-squared:  0.1995, Adjusted R-squared:  0.07955 
## F-statistic: 1.663 on 40 and 267 DF,  p-value: 0.01042
plot(GxE_Fdur_lm0)

hist(GxE_Fdur_lm0$residuals)

#Significant GxE effect when log-transformed but not sqrt()

Anova(GxE_Fdur_lm0, type = 3)
## Anova Table (Type III tests)
## 
## Response: fl_duration
##                     Sum Sq  Df F value    Pr(>F)    
## (Intercept)          15728   1 97.4430 < 2.2e-16 ***
## Recipient             4393  19  1.4325 0.1110745    
## Treatment             2035   1 12.6104 0.0004533 ***
## Location               524   1  3.2491 0.0725889 .  
## Recipient:Treatment   3983  19  1.2988 0.1833232    
## Residuals            43096 267                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Corolla Diam
GxE_Cd_lm0 <- lm(corolla_diam_mm ~ Recipient*Treatment + Location, data = BB_Fplants)
summary(GxE_Cd_lm0)
## 
## Call:
## lm(formula = corolla_diam_mm ~ Recipient * Treatment + Location, 
##     data = BB_Fplants)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.329 -2.504  0.000  2.423  9.409 
## 
## Coefficients: (1 not defined because of singularities)
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            24.831461   2.166052  11.464   <2e-16 ***
## Recipient1             -0.421356   2.316598  -0.182   0.8561    
## Recipient2              0.047907   2.558282   0.019   0.9851    
## Recipient3              0.276518   3.151804   0.088   0.9303    
## Recipient4              0.808038   3.027481   0.267   0.7901    
## Recipient5             -0.286355   2.374705  -0.121   0.9043    
## Recipient6              2.353592   2.306637   1.020   0.3102    
## Recipient7             -0.567281   3.130081  -0.181   0.8566    
## Recipient8             -5.934832   3.047413  -1.947   0.0545 .  
## Recipient9              1.010484   2.610790   0.387   0.6996    
## Recipient10             4.078893   3.024122   1.349   0.1806    
## Recipient11            -1.404488   2.981273  -0.471   0.6387    
## Recipient12             2.791107   2.298540   1.214   0.2277    
## Recipient13            -0.547292   2.453803  -0.223   0.8240    
## Recipient14             0.526095   2.291091   0.230   0.8189    
## Recipient15             0.622225   2.235062   0.278   0.7813    
## Recipient16            -0.684972   2.619997  -0.261   0.7943    
## Recipient17            -2.472411   2.367061  -1.045   0.2989    
## Recipient18            10.154978  35.797790   0.284   0.7773    
## Recipient19            -4.306169   2.942373  -1.464   0.1467    
## Recipient20            -3.203620   2.496061  -1.283   0.2025    
## Treatment1             -1.893005   1.848470  -1.024   0.3084    
## Location               -0.019891   0.009668  -2.057   0.0424 *  
## Recipient1:Treatment1   2.352225   2.404473   0.978   0.3305    
## Recipient2:Treatment1  -0.941907   2.596674  -0.363   0.7176    
## Recipient3:Treatment1  -3.329951   3.213655  -1.036   0.3028    
## Recipient4:Treatment1  -1.084230   3.066302  -0.354   0.7244    
## Recipient5:Treatment1  -1.099513   2.453497  -0.448   0.6551    
## Recipient6:Treatment1   0.457123   2.351878   0.194   0.8463    
## Recipient7:Treatment1   4.337949   3.320822   1.306   0.1946    
## Recipient8:Treatment1  -0.112745   3.160043  -0.036   0.9716    
## Recipient9:Treatment1  -0.458074   2.711053  -0.169   0.8662    
## Recipient10:Treatment1 -0.245309   3.092275  -0.079   0.9369    
## Recipient11:Treatment1  4.657866   2.990033   1.558   0.1226    
## Recipient12:Treatment1 -0.696892   2.345516  -0.297   0.7670    
## Recipient13:Treatment1  1.965994   2.533006   0.776   0.4396    
## Recipient14:Treatment1 -0.612205   2.332819  -0.262   0.7936    
## Recipient15:Treatment1  1.700431   2.264388   0.751   0.4546    
## Recipient16:Treatment1 -2.366163   2.600397  -0.910   0.3652    
## Recipient17:Treatment1 -2.727497   2.455897  -1.111   0.2696    
## Recipient18:Treatment1 -4.755957  35.782405  -0.133   0.8945    
## Recipient19:Treatment1  3.680096   2.990986   1.230   0.2216    
## Recipient20:Treatment1        NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.357 on 94 degrees of freedom
##   (89 observations deleted due to missingness)
## Multiple R-squared:  0.4297, Adjusted R-squared:  0.1809 
## F-statistic: 1.727 on 41 and 94 DF,  p-value: 0.01557
plot(GxE_Cd_lm0)
## Warning: not plotting observations with leverage one:
##   88, 100, 103, 104, 105, 108, 126

hist(GxE_Cd_lm0$residuals)

#Anova(GxE_Cd_lm0, type = 3)

#Biomass
GxE_BIO_lm1<- lm(log(AG_biomass_mg) ~ Treatment*Recipient + Location, data = BB_Fplants)
summary(GxE_BIO_lm1)
## 
## Call:
## lm(formula = log(AG_biomass_mg) ~ Treatment * Recipient + Location, 
##     data = BB_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.8005 -0.3874  0.0000  0.4115  1.5188 
## 
## Coefficients: (5 not defined because of singularities)
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             2.963448   0.415111   7.139 1.87e-09 ***
## Treatment1             -0.324380   0.526988  -0.616   0.5407    
## Recipient1              1.254641   0.615808   2.037   0.0463 *  
## Recipient2              0.122633   0.656787   0.187   0.8525    
## Recipient3              0.075662   0.541317   0.140   0.8893    
## Recipient4             -0.339050   1.076925  -0.315   0.7540    
## Recipient5             -0.094108   0.489908  -0.192   0.8484    
## Recipient6             -0.333997   0.487835  -0.685   0.4963    
## Recipient7              0.516699   0.596778   0.866   0.3902    
## Recipient8             -0.094196   0.633872  -0.149   0.8824    
## Recipient9             -0.480734   0.544929  -0.882   0.3814    
## Recipient10             0.374070   0.559280   0.669   0.5063    
## Recipient11            -0.073496   0.536761  -0.137   0.8916    
## Recipient12             0.226105   0.518772   0.436   0.6646    
## Recipient13             0.940582   1.074998   0.875   0.3853    
## Recipient14             0.634316   0.867155   0.731   0.4675    
## Recipient15            -0.416628   0.552705  -0.754   0.4541    
## Recipient16            -0.218902   0.497355  -0.440   0.6615    
## Recipient17             0.239655   0.560705   0.427   0.6707    
## Recipient18             0.064038   1.212456   0.053   0.9581    
## Recipient19            -0.601921   0.508993  -1.183   0.2419    
## Recipient20             0.571359   0.454923   1.256   0.2143    
## Location               -0.002966   0.002551  -1.162   0.2499    
## Treatment1:Recipient1  -0.377243   0.728877  -0.518   0.6068    
## Treatment1:Recipient2  -0.359942   0.753487  -0.478   0.6347    
## Treatment1:Recipient3  -0.517830   0.653391  -0.793   0.4313    
## Treatment1:Recipient4         NA         NA      NA       NA    
## Treatment1:Recipient5   0.136011   0.615624   0.221   0.8259    
## Treatment1:Recipient6   0.869847   0.607739   1.431   0.1578    
## Treatment1:Recipient7  -0.194714   0.729682  -0.267   0.7905    
## Treatment1:Recipient8   0.023857   0.762582   0.031   0.9752    
## Treatment1:Recipient9   0.368877   0.660130   0.559   0.5785    
## Treatment1:Recipient10  0.036383   0.658607   0.055   0.9561    
## Treatment1:Recipient11  0.222124   0.656248   0.338   0.7362    
## Treatment1:Recipient12  0.275298   0.617586   0.446   0.6575    
## Treatment1:Recipient13        NA         NA      NA       NA    
## Treatment1:Recipient14        NA         NA      NA       NA    
## Treatment1:Recipient15 -0.375889   0.663842  -0.566   0.5735    
## Treatment1:Recipient16  0.621115   0.613801   1.012   0.3159    
## Treatment1:Recipient17  0.095373   0.651056   0.146   0.8841    
## Treatment1:Recipient18        NA         NA      NA       NA    
## Treatment1:Recipient19  0.953002   0.638134   1.493   0.1408    
## Treatment1:Recipient20        NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8834 on 57 degrees of freedom
##   (130 observations deleted due to missingness)
## Multiple R-squared:  0.3981, Adjusted R-squared:  0.007312 
## F-statistic: 1.019 on 37 and 57 DF,  p-value: 0.4669
plot(GxE_BIO_lm1)
## Warning: not plotting observations with leverage one:
##   3, 11, 31, 61, 64, 77, 81

hist(GxE_BIO_lm1$residuals)

#Anova(GxE_BIO_lm1, type = 3)

#Est. Fecundity - high VIFs
GxE_FEC_lm1 <- lm(log(total_est_seed_production) ~ Treatment*Recipient, data = filter(BB_Fplants, surv_to_seedprod == 1))
summary(GxE_FEC_lm1)
## 
## Call:
## lm(formula = log(total_est_seed_production) ~ Treatment * Recipient, 
##     data = filter(BB_Fplants, surv_to_seedprod == 1))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.1809 -0.5280  0.0000  0.5066  2.1462 
## 
## Coefficients: (8 not defined because of singularities)
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             1.47398    0.27833   5.296 2.79e-06 ***
## Treatment1             -0.26722    0.40538  -0.659   0.5129    
## Recipient1              0.32033    0.43246   0.741   0.4624    
## Recipient2              0.04695    0.58611   0.080   0.9365    
## Recipient3              0.78701    0.50740   1.551   0.1273    
## Recipient4              0.52478    0.57940   0.906   0.3695    
## Recipient5             -0.65746    0.92313  -0.712   0.4797    
## Recipient6             -0.37846    0.84340  -0.449   0.6556    
## Recipient7             -0.14466    0.49963  -0.290   0.7734    
## Recipient8             -0.51361    1.12904  -0.455   0.6512    
## Recipient9             -0.23153    0.70713  -0.327   0.7447    
## Recipient10             0.04753    0.50740   0.094   0.9257    
## Recipient11            -0.08768    0.70713  -0.124   0.9018    
## Recipient12             1.27273    0.44583   2.855   0.0063 ** 
## Recipient13            -0.25378    0.46725  -0.543   0.5895    
## Recipient14             0.17314    0.57940   0.299   0.7663    
## Recipient15            -0.54432    0.51505  -1.057   0.2958    
## Recipient16             1.53462    0.58611   2.618   0.0117 *  
## Recipient17             0.52657    0.61223   0.860   0.3939    
## Recipient18            -0.61498    0.80056  -0.768   0.4461    
## Recipient19             0.03569    0.38457   0.093   0.9264    
## Treatment1:Recipient1  -0.04178    0.53808  -0.078   0.9384    
## Treatment1:Recipient2   0.17871    0.69090   0.259   0.7970    
## Treatment1:Recipient3  -0.75131    0.59997  -1.252   0.2164    
## Treatment1:Recipient4        NA         NA      NA       NA    
## Treatment1:Recipient5        NA         NA      NA       NA    
## Treatment1:Recipient6        NA         NA      NA       NA    
## Treatment1:Recipient7   0.70066    0.59997   1.168   0.2485    
## Treatment1:Recipient8        NA         NA      NA       NA    
## Treatment1:Recipient9   0.41106    0.79615   0.516   0.6080    
## Treatment1:Recipient10  0.06523    0.59997   0.109   0.9139    
## Treatment1:Recipient11  0.26722    0.79615   0.336   0.7386    
## Treatment1:Recipient12  0.40326    0.54888   0.735   0.4660    
## Treatment1:Recipient13  0.15775    0.56642   0.279   0.7818    
## Treatment1:Recipient14       NA         NA      NA       NA    
## Treatment1:Recipient15       NA         NA      NA       NA    
## Treatment1:Recipient16 -0.23074    0.69090  -0.334   0.7398    
## Treatment1:Recipient17  0.05842    0.69090   0.085   0.9330    
## Treatment1:Recipient18       NA         NA      NA       NA    
## Treatment1:Recipient19       NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.969 on 49 degrees of freedom
## Multiple R-squared:  0.4694, Adjusted R-squared:  0.1337 
## F-statistic: 1.398 on 31 and 49 DF,  p-value: 0.1442
plot(GxE_FEC_lm1 )
## Warning: not plotting observations with leverage one:
##   1, 15, 18, 27, 50, 57, 58, 81

hist(GxE_FEC_lm1 $residuals)

#poor sample sizes...

#Anova(GxE_FEC_lm1, type = 3)


#not filtered version
GxE_FEC_lm1 <- lm(log(total_est_seed_production+1) ~ Treatment*Recipient + Location, data = BB_Fplants)
summary(GxE_FEC_lm1)
## 
## Call:
## lm(formula = log(total_est_seed_production + 1) ~ Treatment * 
##     Recipient + Location, data = BB_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.0545 -0.5562 -0.0594  0.5517  3.4110 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             0.787164   0.154816   5.085 9.11e-07 ***
## Treatment1             -0.190022   0.073031  -2.602  0.01003 *  
## Recipient1              0.634778   0.291562   2.177  0.03076 *  
## Recipient2             -0.067273   0.293698  -0.229  0.81908    
## Recipient3              0.630463   0.305937   2.061  0.04075 *  
## Recipient4              0.471419   0.335670   1.404  0.16190    
## Recipient5             -0.531484   0.271352  -1.959  0.05168 .  
## Recipient6             -0.441480   0.278092  -1.588  0.11413    
## Recipient7              0.002969   0.286450   0.010  0.99174    
## Recipient8             -0.600392   0.332476  -1.806  0.07260 .  
## Recipient9             -0.365955   0.312343  -1.172  0.24287    
## Recipient10             0.459717   0.343476   1.338  0.18243    
## Recipient11            -0.358700   0.312115  -1.149  0.25196    
## Recipient12             0.661798   0.259532   2.550  0.01160 *  
## Recipient13             0.256727   0.304442   0.843  0.40018    
## Recipient14            -0.177006   0.312286  -0.567  0.57154    
## Recipient15            -0.182747   0.271249  -0.674  0.50134    
## Recipient16             0.205357   0.286514   0.717  0.47445    
## Recipient17             0.294937   0.325984   0.905  0.36679    
## Recipient18            -0.725604   0.523038  -1.387  0.16705    
## Recipient19            -0.380979   0.332366  -1.146  0.25319    
## Recipient20             0.609437   0.344273   1.770  0.07837 .  
## Location               -0.001179   0.001595  -0.739  0.46072    
## Treatment1:Recipient1  -0.172079   0.291540  -0.590  0.55576    
## Treatment1:Recipient2   0.405328   0.296118   1.369  0.17275    
## Treatment1:Recipient3  -0.552983   0.306535  -1.804  0.07289 .  
## Treatment1:Recipient4  -0.970342   0.337457  -2.875  0.00452 ** 
## Treatment1:Recipient5   0.333668   0.271409   1.229  0.22051    
## Treatment1:Recipient6   0.401266   0.277675   1.445  0.15015    
## Treatment1:Recipient7   0.339063   0.284643   1.191  0.23513    
## Treatment1:Recipient8   0.262794   0.332455   0.790  0.43028    
## Treatment1:Recipient9   0.155572   0.312706   0.498  0.61943    
## Treatment1:Recipient10 -0.148248   0.340498  -0.435  0.66380    
## Treatment1:Recipient11  0.109990   0.311911   0.353  0.72477    
## Treatment1:Recipient12  0.153697   0.258168   0.595  0.55236    
## Treatment1:Recipient13 -0.137117   0.303372  -0.452  0.65182    
## Treatment1:Recipient14 -0.339944   0.311916  -1.090  0.27722    
## Treatment1:Recipient15 -0.330496   0.271345  -1.218  0.22480    
## Treatment1:Recipient16  0.373900   0.285060   1.312  0.19129    
## Treatment1:Recipient17 -0.284723   0.323522  -0.880  0.37998    
## Treatment1:Recipient18  0.192616   0.520591   0.370  0.71182    
## Treatment1:Recipient19  0.490070   0.332423   1.474  0.14215    
## Treatment1:Recipient20 -0.177339   0.341265  -0.520  0.60394    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9891 on 182 degrees of freedom
## Multiple R-squared:  0.2912, Adjusted R-squared:  0.1276 
## F-statistic:  1.78 on 42 and 182 DF,  p-value: 0.005161
plot(GxE_FEC_lm1 )
## Warning: not plotting observations with leverage one:
##   145

hist(GxE_FEC_lm1 $residuals)

#Anova(GxE_FEC_lm1, type = 3)

Blue Oak

BO_allplants <- read_csv(here::here("data_sheets", "compiled_sheets", "BO_mastersheet_full_2023-03-01.csv")) %>% select(-c(Sequence, FitP, F_multi, F_plant_notes, Fl_3.11:flr_P, seeds_weighed_d1:msm_d9)) %>% 
  filter(Replicated == "R") %>% #Replicated genotypes only
  mutate(fl_duration = case_when(fl_duration == 0 ~ 1,
                                 TRUE ~ fl_duration)) %>%  #Replace durations of 0 with 1
  mutate(FFD_c = scale(yday(FFD), scale = FALSE)[,1], #convert to Julian day of year, but don't scale...
         fl_dur_c = scale(fl_duration, scale = FALSE)[,1], # Center all variables
         corolla_d_c = scale(corolla_diam_mm, scale = FALSE)[,1],
         AG_biom_c = scale(AG_biomass_mg, scale = FALSE)[,1],
         seed_ct_c = scale(seed_ct, scale = FALSE)[,1],
         lifet_fec_c = scale(total_est_seed_production, scale = FALSE)[,1]) %>% 
  mutate(FFD_z = scale(yday(FFD))[,1],
         fl_dur_z = scale(fl_duration)[,1], # Standardize all variables
         corolla_d_z = scale(corolla_diam_mm)[,1],
         AG_biom_z = scale(AG_biomass_mg)[,1],
         seed_ct_z = scale(seed_ct)[,1],
         lifet_fec_z = scale(total_est_seed_production)[,1]) %>% 
  mutate(seed_ct_r = seed_ct/mean(seed_ct),
         lifet_fec_r = total_est_seed_production/mean(total_est_seed_production)) %>% #fitness relative to population mean
  mutate(Treatment = as.factor(case_when(Block %in% c("1", "2", "3") ~ "ambient",
                               Block == "W" ~ "watered")),
         Treat_bin = as.numeric(case_when(Block %in% c("1", "2", "3") ~ 0, #binary var for treatment: ambient/watered = 0/1
                               Block == "W" ~ 1))) %>% 
  mutate(Recipient = as.factor(Recipient),
         Transect = case_when(Transect == "W1" ~ "13",
                              Transect == "W2" ~ "14",
                              TRUE ~ Transect)) %>% 
  mutate(Transect = as.numeric(Transect))
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 3514 Columns: 82
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (7): Block, Transect, Donor, Recipient, Replicated, F_plant_notes, not...
## dbl  (42): Sequence, Plant_ID, F_plant, closed_fruits_F, open_fruits_F, dama...
## num   (1): F_multi
## lgl  (12): FitP, Rep_FitP, any_FitP, seeds_weighed_d1, seed_mass_mg_d1, seed...
## date (20): Germ_Date, Sow_Date, Plant_Date, Fl_3.11, Fl_3.17, Fl_3.25, Fl_4....
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
BO_allplants_f <- BO_allplants %>% 
  filter(!is.na(FFD_c)) #plants that flowered only

#318 obs vs 225 for fitness plants

##Fitness Plants Only
BO_Fplants <- BO_allplants %>% 
  filter(any_FitP == TRUE)

Main Effects

# FLOWERING DURATION

#*Best* simple linear model -log and sqrt both work?? sqrt+1 results in nice residuals, better adj R2
PL_Fdur_lm0 <- lm(fl_duration ~ Treatment, data = BO_allplants)
summary(PL_Fdur_lm0)
## 
## Call:
## lm(formula = fl_duration ~ Treatment, data = BO_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -31.398 -12.398  -1.779   9.602  48.221 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  23.0884     0.9523  24.245   <2e-16 ***
## Treatment1    9.3098     0.9523   9.776   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 17.2 on 345 degrees of freedom
##   (494 observations deleted due to missingness)
## Multiple R-squared:  0.2169, Adjusted R-squared:  0.2147 
## F-statistic: 95.57 on 1 and 345 DF,  p-value: < 2.2e-16
plot(PL_Fdur_lm0)

hist(PL_Fdur_lm0$residuals)

##UNSURE which transformation is best!

#John's model equivalent
PL_Fdur_lm1 <- lmer(fl_duration ~ Treatment + (1|Recipient) + (1|Transect), data = BO_allplants, REML = T)
summary(PL_Fdur_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: fl_duration ~ Treatment + (1 | Recipient) + (1 | Transect)
##    Data: BO_allplants
## 
## REML criterion at convergence: 2951.3
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -1.99268 -0.64084 -0.06711  0.66623  2.69656 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)   7.567   2.751  
##  Transect  (Intercept)  10.123   3.182  
##  Residual              282.751  16.815  
## Number of obs: 347, groups:  Recipient, 21; Transect, 14
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)   
## (Intercept)   23.121      1.672  2.684   13.83  0.00143 **
## Treatment1     9.210      1.561  2.024    5.90  0.02677 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.482
r.squaredGLMM(PL_Fdur_lm1)
##            R2m       R2c
## [1,] 0.2102194 0.2567208
plot(PL_Fdur_lm1)

#ranef(PL_Fdur_lm1)
##FIRST FLOWERING DATE
#BO_FFD_Model = lmer(FFD_DOY ~ watered + (1|Block) + (1|Recipient), data = BO_final_full, REML = T)

#best lm 
PL_FFD_lm0 <- lm(yday(FFD) ~ Treatment, data = BO_allplants)
summary(PL_FFD_lm0)
## 
## Call:
## lm(formula = yday(FFD) ~ Treatment, data = BO_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -20.569  -6.569  -0.405   6.595  34.431 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  90.9870     0.4742 191.867   <2e-16 ***
## Treatment1   -0.4176     0.4742  -0.881    0.379    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.565 on 345 degrees of freedom
##   (494 observations deleted due to missingness)
## Multiple R-squared:  0.002242,   Adjusted R-squared:  -0.0006497 
## F-statistic: 0.7753 on 1 and 345 DF,  p-value: 0.3792
plot(PL_FFD_lm0)

hist(PL_FFD_lm0$residuals)

#John's model equivalent 
PL_FFD_lm1 <- lmer(yday(FFD) ~ Treatment + (1|Recipient) + (1|Transect), data = BO_allplants)
summary(PL_FFD_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: yday(FFD) ~ Treatment + (1 | Recipient) + (1 | Transect)
##    Data: BO_allplants
## 
## REML criterion at convergence: 2400.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.5630 -0.6428 -0.0639  0.4193  4.6957 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  4.035   2.009   
##  Transect  (Intercept) 20.426   4.519   
##  Residual              53.162   7.291   
## Number of obs: 347, groups:  Recipient, 21; Transect, 14
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  91.6943     1.8402 11.1491  49.828 1.87e-14 ***
## Treatment1   -0.4755     1.7869  9.9741  -0.266    0.796    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.651
r.squaredGLMM(PL_FFD_lm1)
##              R2m       R2c
## [1,] 0.002738201 0.3170029
ranef(PL_FFD_lm1) #Model is singular when using Block instead of Transect
## $Recipient
##        (Intercept)
## BO_004  0.16574680
## BO_021  0.78083771
## BO_024  1.59845766
## BO_025  1.41361906
## BO_048 -1.21286079
## BO_080 -0.55531992
## BO_082 -0.82767747
## BO_086  0.96697436
## BO_126  1.38746087
## BO_127 -0.68430460
## BO_130 -1.01284082
## BO_137 -1.25880100
## BO_142  1.04875665
## BO_149  1.75227004
## BO_151  0.91313836
## BO_152 -3.84750751
## BO_166  0.73051490
## BO_182  1.85828918
## BO_189 -0.09070606
## BO_195 -1.29698277
## BO_199 -1.82906464
## 
## $Transect
##    (Intercept)
## 1    7.8304802
## 2    0.2827365
## 3    2.1305024
## 4    2.2422702
## 5   -0.2314912
## 6   -6.8023600
## 7   -4.1300970
## 8   -3.5125800
## 9   -2.9761993
## 10  -1.5051582
## 11   1.9786611
## 12   4.6932352
## 13  -2.6505307
## 14   2.6505307
## 
## with conditional variances for "Recipient" "Transect"
# COROLLA DIAMETER
#BO_diameter_Model = lmer(corolla_diam_mm ~ watered + (1|Block) + (1|Recipient), data = BO_final, REML = T)

#best lm
PL_Cd_lm0 <- lm(corolla_diam_mm ~ Treatment, data = BO_Fplants)
summary(PL_Cd_lm0)
## 
## Call:
## lm(formula = corolla_diam_mm ~ Treatment, data = BO_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.1823 -2.3761 -0.1261  2.3367 12.0717 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  24.2197     0.2791   86.77   <2e-16 ***
## Treatment1   -0.6616     0.2791   -2.37   0.0189 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.604 on 171 degrees of freedom
##   (74 observations deleted due to missingness)
## Multiple R-squared:  0.03181,    Adjusted R-squared:  0.02615 
## F-statistic: 5.618 on 1 and 171 DF,  p-value: 0.01889
plot(PL_Cd_lm0)

hist(PL_Cd_lm0$residuals)

#John's equivalent model
PL_Cdiam_lm1 <- lmer(corolla_diam_mm ~ Treatment + (1|Transect) + (1|Recipient), data = BO_Fplants)
summary(PL_Cdiam_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: corolla_diam_mm ~ Treatment + (1 | Transect) + (1 | Recipient)
##    Data: BO_Fplants
## 
## REML criterion at convergence: 913.7
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.39328 -0.58046 -0.01401  0.60984  3.13326 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  0.7348  0.8572  
##  Transect  (Intercept)  2.8662  1.6930  
##  Residual              10.0460  3.1695  
## Number of obs: 173, groups:  Recipient, 21; Transect, 13
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  24.1094     0.7248  8.7839  33.266 1.51e-10 ***
## Treatment1   -0.4924     0.6999  7.8405  -0.703    0.502    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.601
r.squaredGLMM(PL_Cdiam_lm1)
##             R2m       R2c
## [1,] 0.01692591 0.2763253
#ranef(PL_Cdiam_lm1) #Both Transect or Block result in singular model...
#Block explains variation in corolla diameter better than treatment or Recipient!
#ABOVEGROUND BIOMASS
#BO_final$log_biomass <- log(BO_final$AG_biomass_mg)
#BO_biomass_Model = lmer(log_biomass ~ watered + (1|Block) + (1|Recipient), data = BO_final, REML = T)

#Best lm
PL_AG_lm0 <- lm(log(AG_biomass_mg) ~ Treatment, data = BO_Fplants)
summary(PL_AG_lm0)
## 
## Call:
## lm(formula = log(AG_biomass_mg) ~ Treatment, data = BO_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.3224 -0.6046 -0.1839  0.5899  2.5370 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.6552     0.2959   8.973 3.34e-13 ***
## Treatment1    0.6189     0.2959   2.091   0.0402 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.003 on 69 degrees of freedom
##   (176 observations deleted due to missingness)
## Multiple R-squared:  0.05962,    Adjusted R-squared:  0.04599 
## F-statistic: 4.374 on 1 and 69 DF,  p-value: 0.04017
plot(PL_AG_lm0)

hist(PL_AG_lm0$residuals)

#Transformation unnecessary? Better R2, marginally NS


#John Equivalent Model
PL_AGbio_lm1 <- lmer(log(AG_biomass_mg) ~ Treatment + (1|Transect) + (1|Recipient), data = BO_Fplants)
## boundary (singular) fit: see help('isSingular')
summary(PL_AGbio_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(AG_biomass_mg) ~ Treatment + (1 | Transect) + (1 | Recipient)
##    Data: BO_Fplants
## 
## REML criterion at convergence: 203
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.3151 -0.6027 -0.1833  0.5881  2.5291 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.000    0.000   
##  Transect  (Intercept) 0.000    0.000   
##  Residual              1.006    1.003   
## Number of obs: 71, groups:  Recipient, 21; Transect, 13
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   2.6552     0.2959 69.0000   8.973 3.34e-13 ***
## Treatment1    0.6189     0.2959 69.0000   2.091   0.0402 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.915
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
r.squaredGLMM(PL_Cdiam_lm1)
##             R2m       R2c
## [1,] 0.01692591 0.2763253
ranef(PL_Cdiam_lm1) #Both Transect or Block result in singular model
## $Recipient
##        (Intercept)
## BO_004 -0.10028797
## BO_021 -0.31427722
## BO_024 -0.52879920
## BO_025  0.50345872
## BO_048 -0.21158919
## BO_080 -0.19410709
## BO_082 -0.25612380
## BO_086 -0.67244146
## BO_126  0.08916078
## BO_127  0.68846970
## BO_130  0.60763721
## BO_137 -0.04760758
## BO_142  0.30773818
## BO_149  0.96290088
## BO_151 -0.55408783
## BO_152 -0.34057534
## BO_166  0.97837520
## BO_182  0.12468689
## BO_189 -0.54567799
## BO_195 -0.54715374
## BO_199  0.05030083
## 
## $Transect
##    (Intercept)
## 1   1.53934650
## 2   1.42130261
## 3   0.86561010
## 5   0.07616374
## 6   0.14656959
## 7   1.47702593
## 8  -2.13706907
## 9  -1.83094299
## 10 -1.29418066
## 11  0.65733619
## 12 -0.92116194
## 13  1.44183619
## 14 -1.44183619
## 
## with conditional variances for "Recipient" "Transect"
#Better model? #random effects don't do it
PL_AGbio_lm2 <- lm(log(AG_biomass_mg) ~ Treatment, data = BO_Fplants)
summary(PL_AGbio_lm2)
## 
## Call:
## lm(formula = log(AG_biomass_mg) ~ Treatment, data = BO_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.3224 -0.6046 -0.1839  0.5899  2.5370 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.6552     0.2959   8.973 3.34e-13 ***
## Treatment1    0.6189     0.2959   2.091   0.0402 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.003 on 69 degrees of freedom
##   (176 observations deleted due to missingness)
## Multiple R-squared:  0.05962,    Adjusted R-squared:  0.04599 
## F-statistic: 4.374 on 1 and 69 DF,  p-value: 0.04017
r.squaredGLMM(PL_Cdiam_lm2)
##             R2m       R2c
## [1,] 0.06929819 0.2188034
ranef(PL_Cdiam_lm2)
## $Location
##      (Intercept)
## 2     1.19838277
## 4     0.79035602
## 5     0.02896805
## 8     0.80353050
## 9     0.30937637
## 10   -0.29820937
## 20    0.17022780
## 26   -0.31938080
## 30    0.50341349
## 34    0.82215204
## 39    0.69464557
## 40   -0.05286850
## 44    0.15392778
## 46    0.00597208
## 47   -0.64341118
## 50    0.43066476
## 52    0.54585612
## 53    0.23698897
## 59   -0.27438370
## 60    0.16921935
## 62   -0.64769414
## 64   -0.02947460
## 67   -0.09658465
## 70   -0.81424854
## 73   -0.49651820
## 76    0.44637536
## 77    0.21478981
## 79   -0.49954694
## 80.5  0.58423475
## 83   -0.63099051
## 84   -0.62240612
## 85    0.82187718
## 86    0.06736266
## 87   -0.06240165
## 88   -0.25663933
## 90   -0.56308617
## 100  -0.52678934
## 110   0.24278958
## 112  -0.16651833
## 113  -0.47823729
## 114  -0.22244929
## 115  -0.15501731
## 120  -1.07043748
## 122  -1.27342225
## 125  -0.01636197
## 129   0.08818279
## 130  -0.33855796
## 132  -0.29466771
## 134  -0.14512267
## 136  -0.66177357
## 140   0.40058366
## 141  -0.21796364
## 143   0.40553462
## 144   0.12760664
## 146   0.25228767
## 147  -0.25242739
## 150   0.38362901
## 151   0.24724707
## 155   0.32995477
## 160   0.65145338
## 
## $Recipient
##        (Intercept)
## BB_017 -0.10687380
## BB_020  0.13401863
## BB_024 -0.04867275
## BB_032  0.05648702
## BB_049 -0.25709783
## BB_051  0.99093569
## BB_059 -0.10039915
## BB_061 -1.61074333
## BB_077  0.16336372
## BB_079  0.80810748
## BB_085  0.55439625
## BB_102  0.95935836
## BB_105 -0.26815302
## BB_118  0.46193623
## BB_137  0.57518627
## BB_143 -0.42551305
## BB_152 -0.99683652
## BB_161  1.70122406
## BB_164 -0.74492948
## BB_185 -0.94752508
## BB_187 -0.89826970
## 
## with conditional variances for "Location" "Recipient"
# FECUNDITY
#BO_final2$log_seedprod <- log(BO_final2$total_est_seed_production)
#BO_seed_Model = lmer(log_seedprod ~ watered + (1|Block) + (1|Recipient), data = BO_final2, REML = T)

#lm
#filtered to individuals that produced seed
PL_fec_lm0 <- lm(log(total_est_seed_production) ~ Treatment, data = filter(BO_Fplants, surv_to_seedprod == 1))
summary(PL_fec_lm0)
## 
## Call:
## lm(formula = log(total_est_seed_production) ~ Treatment, data = filter(BO_Fplants, 
##     surv_to_seedprod == 1))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.1530 -0.9476 -0.0517  0.9011  3.1864 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.8969     0.2439   7.779 4.67e-11 ***
## Treatment1   -0.2561     0.2439  -1.050    0.297    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.144 on 70 degrees of freedom
## Multiple R-squared:  0.01552,    Adjusted R-squared:  0.001452 
## F-statistic: 1.103 on 1 and 70 DF,  p-value: 0.2972
plot(PL_fec_lm0)

hist(PL_fec_lm0$residuals)

#Not filtering data (log+1):
PL_fec_lm0 <- lm(log(total_est_seed_production+1) ~ Treatment, data = BO_Fplants)
summary(PL_fec_lm0)
## 
## Call:
## lm(formula = log(total_est_seed_production + 1) ~ Treatment, 
##     data = BO_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.8136 -0.8136 -0.1520  0.2850  4.0215 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.48279    0.06365   7.585 6.88e-13 ***
## Treatment1   0.33081    0.06365   5.198 4.26e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9693 on 245 degrees of freedom
## Multiple R-squared:  0.09931,    Adjusted R-squared:  0.09564 
## F-statistic: 27.01 on 1 and 245 DF,  p-value: 4.257e-07
plot(PL_fec_lm0)

hist(PL_fec_lm0$residuals)

#John's equivalent model
#Excludes plants that didn't survive to produce seeds!!
PL_fec_lm1 <- lmer(log(total_est_seed_production) ~ Treatment + (1|Recipient) + (1|Transect), data = filter(BO_Fplants, surv_to_seedprod == 1))
summary(PL_fec_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(total_est_seed_production) ~ Treatment + (1 | Recipient) +  
##     (1 | Transect)
##    Data: filter(BO_Fplants, surv_to_seedprod == 1)
## 
## REML criterion at convergence: 218.6
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.09733 -0.51272 -0.00855  0.66302  2.63777 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.01478  0.1216  
##  Transect  (Intercept) 0.37433  0.6118  
##  Residual              1.00533  1.0027  
## Number of obs: 72, groups:  Recipient, 20; Transect, 13
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   1.8513     0.3219 12.1539   5.751 8.71e-05 ***
## Treatment1   -0.3004     0.3210 10.6711  -0.936     0.37    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.732
r.squaredGLMM(PL_fec_lm1)
##             R2m       R2c
## [1,] 0.01965793 0.2932168
#Not filtering -log+1
PL_fec_lm1 <- lmer(log(total_est_seed_production+1) ~ Treatment + (1|Recipient) + (1|Transect), data = BO_Fplants)
summary(PL_fec_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(total_est_seed_production + 1) ~ Treatment + (1 | Recipient) +  
##     (1 | Transect)
##    Data: BO_Fplants
## 
## REML criterion at convergence: 676.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.7379 -0.6135 -0.2180  0.1209  4.1508 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.03832  0.1958  
##  Transect  (Intercept) 0.15705  0.3963  
##  Residual              0.80373  0.8965  
## Number of obs: 247, groups:  Recipient, 21; Transect, 14
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)  
## (Intercept)   0.4785     0.1691 7.7493   2.829   0.0229 *
## Treatment1    0.3106     0.1636 6.6201   1.899   0.1018  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.612
r.squaredGLMM(PL_fec_lm1)
##             R2m       R2c
## [1,] 0.08343205 0.2626587

GxE Effects in BO

#FFD
GxE_FFD_lm0 <- lm(yday(FFD) ~ Recipient*Treatment + Transect, data = BO_allplants)
summary(GxE_FFD_lm0)
## 
## Call:
## lm(formula = yday(FFD) ~ Recipient * Treatment + Transect, data = BO_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -16.442  -4.521  -0.929   4.314  31.788 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            93.62200    1.75562  53.327  < 2e-16 ***
## Recipient1              1.00421    2.31578   0.434 0.664859    
## Recipient2              1.52407    1.79906   0.847 0.397579    
## Recipient3              3.47097    2.00792   1.729 0.084890 .  
## Recipient4              0.30032    1.96926   0.153 0.878891    
## Recipient5             -1.17887    2.09361  -0.563 0.573796    
## Recipient6             -3.03816    4.07112  -0.746 0.456080    
## Recipient7              0.12822    1.77470   0.072 0.942453    
## Recipient8              2.35136    2.09453   1.123 0.262486    
## Recipient9              1.71522    1.93088   0.888 0.375075    
## Recipient10             0.43503    2.53812   0.171 0.864025    
## Recipient11            -2.42233    1.93158  -1.254 0.210783    
## Recipient12            -3.92241    2.11396  -1.855 0.064496 .  
## Recipient13             0.75322    2.09389   0.360 0.719306    
## Recipient14             5.68260    4.05431   1.402 0.162049    
## Recipient15             1.67401    2.02140   0.828 0.408239    
## Recipient16            -6.78441    1.94875  -3.481 0.000572 ***
## Recipient17             1.96778    1.80618   1.089 0.276810    
## Recipient18             4.35850    1.93241   2.255 0.024814 *  
## Recipient19            -1.84226    2.00779  -0.918 0.359577    
## Recipient20            -2.03968    2.21461  -0.921 0.357774    
## Treatment1             -1.24509    0.72925  -1.707 0.088778 .  
## Transect               -0.24450    0.16330  -1.497 0.135381    
## Recipient1:Treatment1  -0.41194    2.31581  -0.178 0.858934    
## Recipient2:Treatment1   4.91490    1.79888   2.732 0.006659 ** 
## Recipient3:Treatment1  -7.69440    2.00761  -3.833 0.000154 ***
## Recipient4:Treatment1  -0.17772    1.96913  -0.090 0.928147    
## Recipient5:Treatment1  -1.73840    2.09373  -0.830 0.407027    
## Recipient6:Treatment1   4.40598    4.07417   1.081 0.280358    
## Recipient7:Treatment1   2.48535    1.77446   1.401 0.162347    
## Recipient8:Treatment1   1.03999    2.09360   0.497 0.619727    
## Recipient9:Treatment1   0.28161    1.93053   0.146 0.884121    
## Recipient10:Treatment1 -6.12084    2.53874  -2.411 0.016503 *  
## Recipient11:Treatment1 -2.51784    1.93182  -1.303 0.193441    
## Recipient12:Treatment1  0.96622    2.11318   0.457 0.647828    
## Recipient13:Treatment1  2.52702    2.09369   1.207 0.228383    
## Recipient14:Treatment1 -0.87326    4.05368  -0.215 0.829580    
## Recipient15:Treatment1 -0.09294    2.02115  -0.046 0.963352    
## Recipient16:Treatment1  0.86347    1.95030   0.443 0.658271    
## Recipient17:Treatment1  1.90824    1.80659   1.056 0.291685    
## Recipient18:Treatment1 -0.91480    1.93239  -0.473 0.636266    
## Recipient19:Treatment1  0.81144    2.00902   0.404 0.686572    
## Recipient20:Treatment1  1.25335    2.21087   0.567 0.571197    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.094 on 304 degrees of freedom
##   (494 observations deleted due to missingness)
## Multiple R-squared:  0.2148, Adjusted R-squared:  0.1063 
## F-statistic:  1.98 on 42 and 304 DF,  p-value: 0.0005862
plot(GxE_FFD_lm0)
## Warning: not plotting observations with leverage one:
##   320, 347

hist(GxE_FFD_lm0$residuals)

#Anova(GxE_FFD_lm0, type = 3)


#Flowering Duration
GxE_Fdur_lm0 <- lm(fl_duration ~ Recipient*Treatment + Transect, data = BO_allplants)
summary(GxE_Fdur_lm0)
## 
## Call:
## lm(formula = fl_duration ~ Recipient * Treatment + Transect, 
##     data = BO_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -38.194  -9.656   0.000  10.011  36.991 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             18.0357     3.6561   4.933 1.34e-06 ***
## Recipient1              -6.3426     4.8226  -1.315   0.1894    
## Recipient2               3.6662     3.7465   0.979   0.3286    
## Recipient3               4.5817     4.1815   1.096   0.2741    
## Recipient4              -6.5405     4.1010  -1.595   0.1118    
## Recipient5               4.6716     4.3599   1.071   0.2848    
## Recipient6              -4.8103     8.4781  -0.567   0.5709    
## Recipient7               1.8575     3.6958   0.503   0.6156    
## Recipient8              -4.4532     4.3618  -1.021   0.3081    
## Recipient9              -5.1159     4.0210  -1.272   0.2042    
## Recipient10              0.2240     5.2856   0.042   0.9662    
## Recipient11              1.3733     4.0225   0.341   0.7330    
## Recipient12             -0.3718     4.4023  -0.084   0.9327    
## Recipient13             -2.6148     4.3605  -0.600   0.5492    
## Recipient14              2.4312     8.4431   0.288   0.7736    
## Recipient15             -1.8805     4.2095  -0.447   0.6554    
## Recipient16              5.4511     4.0583   1.343   0.1802    
## Recipient17              3.4983     3.7614   0.930   0.3531    
## Recipient18             -4.0460     4.0242  -1.005   0.3155    
## Recipient19              1.1596     4.1812   0.277   0.7817    
## Recipient20             11.6010     4.6119   2.515   0.0124 *  
## Treatment1              10.7005     1.5187   7.046 1.24e-11 ***
## Transect                 0.4692     0.3401   1.380   0.1687    
## Recipient1:Treatment1   -2.4211     4.8227  -0.502   0.6160    
## Recipient2:Treatment1   -3.1114     3.7462  -0.831   0.4069    
## Recipient3:Treatment1   -0.1441     4.1808  -0.034   0.9725    
## Recipient4:Treatment1   -1.4392     4.1007  -0.351   0.7259    
## Recipient5:Treatment1    6.9293     4.3602   1.589   0.1130    
## Recipient6:Treatment1   -4.9064     8.4844  -0.578   0.5635    
## Recipient7:Treatment1    5.4485     3.6953   1.474   0.1414    
## Recipient8:Treatment1   -0.3519     4.3599  -0.081   0.9357    
## Recipient9:Treatment1   -2.6133     4.0203  -0.650   0.5162    
## Recipient10:Treatment1   4.1279     5.2869   0.781   0.4355    
## Recipient11:Treatment1  -4.2008     4.0230  -1.044   0.2972    
## Recipient12:Treatment1   6.2628     4.4007   1.423   0.1557    
## Recipient13:Treatment1   0.4763     4.3601   0.109   0.9131    
## Recipient14:Treatment1   3.3350     8.4418   0.395   0.6931    
## Recipient15:Treatment1   2.2887     4.2090   0.544   0.5870    
## Recipient16:Treatment1   6.6306     4.0615   1.633   0.1036    
## Recipient17:Treatment1  -1.1328     3.7622  -0.301   0.7635    
## Recipient18:Treatment1  -1.2675     4.0242  -0.315   0.7530    
## Recipient19:Treatment1   4.2327     4.1838   1.012   0.3125    
## Recipient20:Treatment1 -11.7890     4.6041  -2.561   0.0109 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 16.86 on 304 degrees of freedom
##   (494 observations deleted due to missingness)
## Multiple R-squared:  0.3373, Adjusted R-squared:  0.2457 
## F-statistic: 3.684 on 42 and 304 DF,  p-value: 2.261e-11
plot(GxE_Fdur_lm0)
## Warning: not plotting observations with leverage one:
##   320, 347

hist(GxE_Fdur_lm0$residuals)

#Significant GxE effect when log-transformed but not sqrt()


#Anova(GxE_Fdur_lm0, type = 3)


#Corolla Diam
GxE_Cd_lm0 <- lm(corolla_diam_mm ~ Recipient*Treatment + Transect, data = BO_Fplants)
summary(GxE_Cd_lm0)
## 
## Call:
## lm(formula = corolla_diam_mm ~ Recipient * Treatment + Transect, 
##     data = BO_Fplants)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.255 -1.865  0.020  2.023 10.982 
## 
## Coefficients: (2 not defined because of singularities)
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             28.51834    1.64050  17.384  < 2e-16 ***
## Recipient1              -1.01711    1.87588  -0.542 0.588592    
## Recipient2              -2.58169    1.71849  -1.502 0.135409    
## Recipient3              -2.07495    1.77002  -1.172 0.243199    
## Recipient4               1.62000    1.79061   0.905 0.367262    
## Recipient5              -1.53924    1.70041  -0.905 0.367000    
## Recipient6              10.80595   25.18159   0.429 0.668535    
## Recipient7              -1.62497    1.74072  -0.934 0.352263    
## Recipient8              -1.99036    1.76798  -1.126 0.262299    
## Recipient9              -0.85799    2.08860  -0.411 0.681888    
## Recipient10              0.28058    1.91506   0.147 0.883740    
## Recipient11              0.56812    1.91447   0.297 0.767124    
## Recipient12              0.51443    1.76758   0.291 0.771480    
## Recipient13              0.62504    1.76765   0.354 0.724201    
## Recipient14              4.11320    1.63136   2.521 0.012881 *  
## Recipient15             -1.78467    1.66077  -1.075 0.284512    
## Recipient16             -1.46016    1.74125  -0.839 0.403226    
## Recipient17              1.83954    1.66666   1.104 0.271719    
## Recipient18             -0.11650    1.72380  -0.068 0.946221    
## Recipient19             -1.58836    1.76798  -0.898 0.370605    
## Recipient20             -2.93621    1.87441  -1.566 0.119634    
## Treatment1              -2.58050    1.38844  -1.859 0.065317 .  
## Transect                -0.35688    0.09504  -3.755 0.000259 ***
## Recipient1:Treatment1    2.38522    1.95458   1.220 0.224518    
## Recipient2:Treatment1   -1.36496    1.76679  -0.773 0.441163    
## Recipient3:Treatment1   -0.18784    1.83159  -0.103 0.918471    
## Recipient4:Treatment1    1.53612    1.83183   0.839 0.403225    
## Recipient5:Treatment1   -0.47522    1.74237  -0.273 0.785476    
## Recipient6:Treatment1  -11.33126   25.12597  -0.451 0.652745    
## Recipient7:Treatment1    1.96223    1.77610   1.105 0.271256    
## Recipient8:Treatment1    1.23676    1.80590   0.685 0.494642    
## Recipient9:Treatment1   -1.26897    2.15880  -0.588 0.557663    
## Recipient10:Treatment1   1.93316    1.95701   0.988 0.325052    
## Recipient11:Treatment1  -1.94839    2.00102  -0.974 0.331986    
## Recipient12:Treatment1  -0.35078    1.80631  -0.194 0.846320    
## Recipient13:Treatment1  -0.27450    1.80699  -0.152 0.879489    
## Recipient14:Treatment1        NA         NA      NA       NA    
## Recipient15:Treatment1   1.14784    1.69956   0.675 0.500619    
## Recipient16:Treatment1   1.60363    1.77334   0.904 0.367484    
## Recipient17:Treatment1   2.32827    1.70057   1.369 0.173288    
## Recipient18:Treatment1   1.03224    1.77218   0.582 0.561246    
## Recipient19:Treatment1   0.94480    1.80631   0.523 0.601812    
## Recipient20:Treatment1        NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.344 on 132 degrees of freedom
##   (74 observations deleted due to missingness)
## Multiple R-squared:  0.3566, Adjusted R-squared:  0.1617 
## F-statistic: 1.829 on 40 and 132 DF,  p-value: 0.005834
plot(GxE_Cd_lm0)

hist(GxE_Cd_lm0$residuals)

#Biomass
GxE_BIO_lm1<- lm(log(AG_biomass_mg) ~ Treatment*Recipient + Transect, data = BO_Fplants)
summary(GxE_BIO_lm1)
## 
## Call:
## lm(formula = log(AG_biomass_mg) ~ Treatment * Recipient + Transect, 
##     data = BO_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.8607 -0.4485  0.0000  0.4147  1.9655 
## 
## Coefficients: (18 not defined because of singularities)
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             2.84553    0.75262   3.781 0.000449 ***
## Treatment1              0.84581    0.59084   1.432 0.159039    
## Recipient1             -1.02747    0.69955  -1.469 0.148703    
## Recipient2             -0.25346    0.57383  -0.442 0.660784    
## Recipient3              0.58238    0.78169   0.745 0.460045    
## Recipient4             -0.02677    0.69192  -0.039 0.969310    
## Recipient5              0.68671    0.57219   1.200 0.236225    
## Recipient6             -0.23202    0.49840  -0.466 0.643750    
## Recipient7             -0.37548    0.41443  -0.906 0.369652    
## Recipient8              0.83487    0.70815   1.179 0.244479    
## Recipient9             -0.57881    0.45019  -1.286 0.204984    
## Recipient10             0.20174    0.57219   0.353 0.726021    
## Recipient11             0.09527    0.80580   0.118 0.906404    
## Recipient12             0.20117    0.57846   0.348 0.729606    
## Recipient13            -0.37900    0.49927  -0.759 0.451663    
## Recipient14            -0.60415    0.71346  -0.847 0.401499    
## Recipient15             0.37388    0.49778   0.751 0.456418    
## Recipient16             1.56944    0.58458   2.685 0.010059 *  
## Recipient17             0.67746    0.96721   0.700 0.487189    
## Recipient18            -0.22853    0.49935  -0.458 0.649358    
## Recipient19             0.03301    0.50176   0.066 0.947829    
## Recipient20             0.14403    0.70333   0.205 0.838646    
## Transect               -0.04757    0.04483  -1.061 0.294253    
## Treatment1:Recipient1        NA         NA      NA       NA    
## Treatment1:Recipient2        NA         NA      NA       NA    
## Treatment1:Recipient3  -1.24846    0.78310  -1.594 0.117727    
## Treatment1:Recipient4        NA         NA      NA       NA    
## Treatment1:Recipient5        NA         NA      NA       NA    
## Treatment1:Recipient6        NA         NA      NA       NA    
## Treatment1:Recipient7        NA         NA      NA       NA    
## Treatment1:Recipient8        NA         NA      NA       NA    
## Treatment1:Recipient9        NA         NA      NA       NA    
## Treatment1:Recipient10       NA         NA      NA       NA    
## Treatment1:Recipient11 -0.36234    0.80963  -0.448 0.656585    
## Treatment1:Recipient12       NA         NA      NA       NA    
## Treatment1:Recipient13       NA         NA      NA       NA    
## Treatment1:Recipient14       NA         NA      NA       NA    
## Treatment1:Recipient15       NA         NA      NA       NA    
## Treatment1:Recipient16       NA         NA      NA       NA    
## Treatment1:Recipient17       NA         NA      NA       NA    
## Treatment1:Recipient18       NA         NA      NA       NA    
## Treatment1:Recipient19       NA         NA      NA       NA    
## Treatment1:Recipient20       NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.007 on 46 degrees of freedom
##   (176 observations deleted due to missingness)
## Multiple R-squared:  0.3682, Adjusted R-squared:  0.0385 
## F-statistic: 1.117 on 24 and 46 DF,  p-value: 0.3643
plot(GxE_BIO_lm1)
## Warning: not plotting observations with leverage one:
##   33, 69, 70, 71

hist(GxE_BIO_lm1$residuals)

#Est. Fecundity
GxE_FEC_lm1 <- lm(log(total_est_seed_production) ~ Treatment*Recipient, data = filter(BO_Fplants, surv_to_seedprod == 1))
summary(GxE_FEC_lm1)
## 
## Call:
## lm(formula = log(total_est_seed_production) ~ Treatment * Recipient, 
##     data = filter(BO_Fplants, surv_to_seedprod == 1))
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2085 -0.5388  0.0000  0.3546  1.9127 
## 
## Coefficients: (16 not defined because of singularities)
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              2.0601     0.5278   3.903 0.000296 ***
## Treatment1              -0.4848     0.5745  -0.844 0.402943    
## Recipient1              -0.5356     0.7092  -0.755 0.453825    
## Recipient2              -0.4724     0.6677  -0.707 0.482700    
## Recipient3              -0.1434     0.8682  -0.165 0.869549    
## Recipient4              -0.1346     0.4667  -0.288 0.774242    
## Recipient5              -0.1623     0.4315  -0.376 0.708382    
## Recipient6              -1.5753     0.9891  -1.593 0.117781    
## Recipient7               0.7009     0.5870   1.194 0.238317    
## Recipient8              -0.1869     0.4315  -0.433 0.666746    
## Recipient9               1.6066     0.5870   2.737 0.008671 ** 
## Recipient10             -1.0399     0.8051  -1.292 0.202691    
## Recipient11              0.7009     0.5151   1.361 0.179973    
## Recipient12             -0.9781     0.5870  -1.666 0.102189    
## Recipient13             -0.7423     0.5151  -1.441 0.156105    
## Recipient14             -0.1890     0.7092  -0.267 0.790982    
## Recipient15              0.8066     0.4044   1.995 0.051785 .  
## Recipient16             -1.1132     0.5870  -1.896 0.063930 .  
## Recipient17              0.6332     0.4888   1.295 0.201409    
## Recipient18             -0.4767     0.9891  -0.482 0.632013    
## Recipient19              1.3470     1.4628   0.921 0.361768    
## Treatment1:Recipient1        NA         NA      NA       NA    
## Treatment1:Recipient2    0.5746     0.7114   0.808 0.423193    
## Treatment1:Recipient3   -0.4511     0.9263  -0.487 0.628466    
## Treatment1:Recipient4        NA         NA      NA       NA    
## Treatment1:Recipient5        NA         NA      NA       NA    
## Treatment1:Recipient6        NA         NA      NA       NA    
## Treatment1:Recipient7        NA         NA      NA       NA    
## Treatment1:Recipient8        NA         NA      NA       NA    
## Treatment1:Recipient9        NA         NA      NA       NA    
## Treatment1:Recipient10   1.5050     0.8521   1.766 0.083714 .  
## Treatment1:Recipient11       NA         NA      NA       NA    
## Treatment1:Recipient12       NA         NA      NA       NA    
## Treatment1:Recipient13       NA         NA      NA       NA    
## Treatment1:Recipient14       NA         NA      NA       NA    
## Treatment1:Recipient15       NA         NA      NA       NA    
## Treatment1:Recipient16       NA         NA      NA       NA    
## Treatment1:Recipient17       NA         NA      NA       NA    
## Treatment1:Recipient18       NA         NA      NA       NA    
## Treatment1:Recipient19       NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.028 on 48 degrees of freedom
## Multiple R-squared:  0.4551, Adjusted R-squared:  0.1939 
## F-statistic: 1.743 on 23 and 48 DF,  p-value: 0.05246
plot(GxE_FEC_lm1 )
## Warning: not plotting observations with leverage one:
##   11, 18, 64, 69, 70, 71, 72

hist(GxE_FEC_lm1 $residuals)

#poor sample sizes...

#not filtered version
GxE_FEC_lm1 <- lm(log(total_est_seed_production+1) ~ Treatment*Recipient + Transect, data = BO_Fplants)
summary(GxE_FEC_lm1)
## 
## Call:
## lm(formula = log(total_est_seed_production + 1) ~ Treatment * 
##     Recipient + Transect, data = BO_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.0244 -0.4591 -0.0092  0.0538  3.3337 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)   
## (Intercept)             0.65470    0.21640   3.025  0.00280 **
## Treatment1              0.26917    0.09539   2.822  0.00525 **
## Recipient1             -0.20892    0.27312  -0.765  0.44519   
## Recipient2              0.45096    0.23985   1.880  0.06151 . 
## Recipient3             -0.10261    0.25794  -0.398  0.69120   
## Recipient4             -0.47033    0.30329  -1.551  0.12251   
## Recipient5              0.17083    0.26443   0.646  0.51898   
## Recipient6              0.24835    0.47207   0.526  0.59940   
## Recipient7             -0.43042    0.23973  -1.795  0.07407 . 
## Recipient8              0.03492    0.30891   0.113  0.91011   
## Recipient9              0.08520    0.25270   0.337  0.73635   
## Recipient10             0.23343    0.30897   0.756  0.45081   
## Recipient11            -0.07174    0.26448  -0.271  0.78647   
## Recipient12             0.20759    0.28191   0.736  0.46237   
## Recipient13            -0.27491    0.25791  -1.066  0.28773   
## Recipient14            -0.11649    0.47204  -0.247  0.80533   
## Recipient15            -0.25633    0.24534  -1.045  0.29736   
## Recipient16             0.49722    0.27092   1.835  0.06792 . 
## Recipient17            -0.24866    0.25258  -0.985  0.32603   
## Recipient18             0.53873    0.26454   2.036  0.04299 * 
## Recipient19            -0.36493    0.28197  -1.294  0.19705   
## Recipient20             0.03173    0.30096   0.105  0.91615   
## Transect               -0.01832    0.02038  -0.899  0.36969   
## Treatment1:Recipient1  -0.07074    0.27313  -0.259  0.79590   
## Treatment1:Recipient2   0.02227    0.23986   0.093  0.92613   
## Treatment1:Recipient3  -0.54434    0.25791  -2.111  0.03602 * 
## Treatment1:Recipient4  -0.32299    0.30342  -1.065  0.28835   
## Treatment1:Recipient5   0.31084    0.26445   1.175  0.24121   
## Treatment1:Recipient6   0.37736    0.47230   0.799  0.42523   
## Treatment1:Recipient7  -0.29225    0.23973  -1.219  0.22423   
## Treatment1:Recipient8   0.18226    0.30890   0.590  0.55583   
## Treatment1:Recipient9   0.22154    0.25268   0.877  0.38163   
## Treatment1:Recipient10  0.36244    0.30887   1.173  0.24199   
## Treatment1:Recipient11 -0.07036    0.26452  -0.266  0.79051   
## Treatment1:Recipient12  0.35034    0.28191   1.243  0.21539   
## Treatment1:Recipient13 -0.13490    0.25789  -0.523  0.60147   
## Treatment1:Recipient14  0.01252    0.47221   0.027  0.97887   
## Treatment1:Recipient15 -0.11815    0.24532  -0.482  0.63060   
## Treatment1:Recipient16  0.63998    0.27097   2.362  0.01913 * 
## Treatment1:Recipient17 -0.11049    0.25255  -0.437  0.66223   
## Treatment1:Recipient18  0.03496    0.26449   0.132  0.89497   
## Treatment1:Recipient19 -0.22217    0.28211  -0.788  0.43188   
## Treatment1:Recipient20 -0.81268    0.30076  -2.702  0.00747 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.9193 on 204 degrees of freedom
## Multiple R-squared:  0.3255, Adjusted R-squared:  0.1866 
## F-statistic: 2.344 on 42 and 204 DF,  p-value: 4.424e-05
plot(GxE_FEC_lm1 )
## Warning: not plotting observations with leverage one:
##   221, 247

hist(GxE_FEC_lm1 $residuals)

Hastings

HR_allplants <- read_csv(here::here("data_sheets", "compiled_sheets", "HR_mastersheet_full_2023-03-01.csv")) %>% select(-c(Sequence, FitP, F_multi, F_plant_notes, Fl_3.10:flr_P, seeds_weighed_d1:msm_d9)) %>% 
  filter(Replicated == "R") %>% #Replicated genotypes only
  mutate(fl_duration = case_when(fl_duration == 0 ~ 1,
                                 TRUE ~ fl_duration)) %>%  #Replace durations of 0 with 1
  mutate(FFD_c = scale(yday(FFD), scale = FALSE)[,1], #convert to Julian day of year, but don't scale...
         fl_dur_c = scale(fl_duration, scale = FALSE)[,1], # Center all variables
         corolla_d_c = scale(corolla_diam_mm, scale = FALSE)[,1],
         AG_biom_c = scale(AG_biomass_mg, scale = FALSE)[,1],
         seed_ct_c = scale(seed_ct, scale = FALSE)[,1],
         lifet_fec_c = scale(total_est_seed_production, scale = FALSE)[,1]) %>% 
  mutate(FFD_z = scale(yday(FFD))[,1],
         fl_dur_z = scale(fl_duration)[,1], # Standardize all variables
         corolla_d_z = scale(corolla_diam_mm)[,1],
         AG_biom_z = scale(AG_biomass_mg)[,1],
         seed_ct_z = scale(seed_ct)[,1],
         lifet_fec_z = scale(total_est_seed_production)[,1]) %>% 
  mutate(seed_ct_r = seed_ct/mean(seed_ct),
         lifet_fec_r = total_est_seed_production/mean(total_est_seed_production)) %>% #fitness relative to population mean
  mutate(Treatment = as.factor(case_when(Block %in% c("1", "2", "3") ~ "ambient",
                               Block == "W" ~ "watered")),
         Treat_bin = as.numeric(case_when(Block %in% c("1", "2", "3") ~ 0, #binary var for treatment: ambient/watered = 0/1
                               Block == "W" ~ 1))) %>% 
  mutate(Recipient = as.factor(Recipient),
         Transect = case_when(Transect == "W1" ~ "10",
                              Transect == "W2" ~ "11",
                              TRUE ~ Transect)) %>% 
  mutate(Transect = as.numeric(Transect))
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 3624 Columns: 82
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr   (7): Block, Transect, Donor, Recipient, Replicated, F_plant_notes, not...
## dbl  (39): Sequence, Plant_ID, F_plant, closed_fruits_F, open_fruits_F, dama...
## num   (1): F_multi
## lgl  (15): FitP, Rep_FitP, any_FitP, seeds_weighed_d1, seed_mass_mg_d1, seed...
## date (20): Germ_Date, Sow_Date, Plant_Date, Fl_3.10, Fl_3.16, Fl_3.24, Fl_3....
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
HR_allplants_f <- HR_allplants %>% 
  filter(!is.na(FFD_c)) #plants that flowered only

#318 obs vs 225 for fitness plants

##Fitness Plants Only
HR_Fplants <- HR_allplants %>% 
  filter(any_FitP == TRUE)

Main Effects - HR

# FLOWERING DURATION

#*Best* simple linear model -log and sqrt both work?? sqrt+1 results in nice residuals, better adj R2
PL_Fdur_lm0 <- lm(fl_duration ~ Treatment, data = HR_allplants)
summary(PL_Fdur_lm0)
## 
## Call:
## lm(formula = fl_duration ~ Treatment, data = HR_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -22.892  -9.243  -2.243   3.757  41.757 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  23.5674     0.4177  56.421   <2e-16 ***
## Treatment1   -0.3248     0.4177  -0.778    0.437    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.11 on 732 degrees of freedom
##   (106 observations deleted due to missingness)
## Multiple R-squared:  0.0008256,  Adjusted R-squared:  -0.0005394 
## F-statistic: 0.6048 on 1 and 732 DF,  p-value: 0.437
plot(PL_Fdur_lm0)

hist(PL_Fdur_lm0$residuals)

##UNSURE which transformation is best!

#John's model equivalent
PL_Fdur_lm1 <- lmer(fl_duration ~ Treatment + (1|Recipient) + (1|Transect), data = HR_allplants, REML = T)
summary(PL_Fdur_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: fl_duration ~ Treatment + (1 | Recipient) + (1 | Transect)
##    Data: HR_allplants
## 
## REML criterion at convergence: 5575
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.4263 -0.6271 -0.0229  0.5627  3.8173 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  10.916   3.304  
##  Transect  (Intercept)   1.819   1.349  
##  Residual              111.314  10.551  
## Number of obs: 734, groups:  Recipient, 21; Transect, 11
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  23.6998     0.9796 15.2982  24.193  1.3e-13 ***
## Treatment1   -0.2728     0.6634  4.7556  -0.411    0.699    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.312
r.squaredGLMM(PL_Fdur_lm1)
##               R2m       R2c
## [1,] 0.0005787491 0.1031777
plot(PL_Fdur_lm1)

#ranef(PL_Fdur_lm1)
##FIRST FLOWERING DATE

#best lm 
PL_FFD_lm0 <- lm(yday(FFD) ~ Treatment + Transect, data = HR_allplants)
summary(PL_FFD_lm0)
## 
## Call:
## lm(formula = yday(FFD) ~ Treatment + Transect, data = HR_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -18.102  -3.462  -0.142   3.150  27.218 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 99.93641    0.78101  127.96   <2e-16 ***
## Treatment1  -3.51394    0.32369  -10.86   <2e-16 ***
## Transect    -1.66006    0.09718  -17.08   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.053 on 731 degrees of freedom
##   (106 observations deleted due to missingness)
## Multiple R-squared:  0.3028, Adjusted R-squared:  0.3009 
## F-statistic: 158.7 on 2 and 731 DF,  p-value: < 2.2e-16
plot(PL_FFD_lm0)

hist(PL_FFD_lm0$residuals)

#John's model equivalent 
PL_FFD_lm1 <- lmer(yday(FFD) ~ Treatment + (1|Recipient) + (1|Transect), data = HR_allplants)
summary(PL_FFD_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: yday(FFD) ~ Treatment + (1 | Recipient) + (1 | Transect)
##    Data: HR_allplants
## 
## REML criterion at convergence: 4460
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3719 -0.5909 -0.1701  0.7288  5.4346 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept)  1.989   1.410   
##  Transect  (Intercept) 18.761   4.331   
##  Residual              23.448   4.842   
## Number of obs: 734, groups:  Recipient, 21; Transect, 11
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   87.053      1.731  9.112  50.289 1.87e-12 ***
## Treatment1     1.020      1.703  8.550   0.599    0.565    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.620
r.squaredGLMM(PL_FFD_lm1)
##             R2m       R2c
## [1,] 0.02220911 0.4812601
ranef(PL_FFD_lm1) #Model is singular when using Block instead of Transect
## $Recipient
##        (Intercept)
## HR_015  -1.1877824
## HR_017   0.3098427
## HR_040   1.6018754
## HR_043   0.2989777
## HR_044   0.8768283
## HR_056   0.5353734
## HR_059   0.1511706
## HR_064   0.6997262
## HR_071   0.9540551
## HR_080   0.2794691
## HR_101  -1.1147781
## HR_112  -0.5040519
## HR_119  -1.8546553
## HR_142   0.7558583
## HR_145   0.7018126
## HR_146  -3.2109503
## HR_148  -1.0150958
## HR_149  -1.3664840
## HR_162   1.1295445
## HR_180   0.8397054
## HR_184   1.1195586
## 
## $Transect
##    (Intercept)
## 1    7.4333526
## 2    4.6208236
## 3    1.3919086
## 4    2.5983763
## 5    0.7046886
## 6   -2.8284551
## 7   -3.2018153
## 8   -4.7135608
## 9   -6.0053186
## 10   0.8429974
## 11  -0.8429974
## 
## with conditional variances for "Recipient" "Transect"
# COROLLA DIAMETER
#HR_diameter_Model = lmer(corolla_diam_mm ~ watered + (1|Block) + (1|Recipient), data = HR_final, REML = T)

#best lm
PL_Cd_lm0 <- lm(corolla_diam_mm ~ Treatment, data = HR_Fplants)
summary(PL_Cd_lm0)
## 
## Call:
## lm(formula = corolla_diam_mm ~ Treatment, data = HR_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.0027 -1.7977  0.1956  1.8438  5.6793 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 22.15242    0.19658 112.688   <2e-16 ***
## Treatment1  -0.04171    0.19658  -0.212    0.832    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.474 on 216 degrees of freedom
##   (95 observations deleted due to missingness)
## Multiple R-squared:  0.0002084,  Adjusted R-squared:  -0.00442 
## F-statistic: 0.04503 on 1 and 216 DF,  p-value: 0.8322
plot(PL_Cd_lm0)

hist(PL_Cd_lm0$residuals)

#John's equivalent model
PL_Cdiam_lm1 <- lmer(corolla_diam_mm ~ Treatment + (1|Transect) + (1|Recipient), data = HR_Fplants)
summary(PL_Cdiam_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: corolla_diam_mm ~ Treatment + (1 | Transect) + (1 | Recipient)
##    Data: HR_Fplants
## 
## REML criterion at convergence: 1003.4
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.36670 -0.72503 -0.00741  0.75336  2.28435 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.4479   0.6692  
##  Transect  (Intercept) 0.6724   0.8200  
##  Residual              5.2235   2.2855  
## Number of obs: 218, groups:  Recipient, 21; Transect, 11
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  22.0801     0.4001  7.9492  55.192 1.47e-11 ***
## Treatment1    0.0472     0.3729  6.0654   0.127    0.903    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.563
r.squaredGLMM(PL_Cdiam_lm1)
##               R2m       R2c
## [1,] 0.0002562942 0.1768065
#ranef(PL_Cdiam_lm1) #Both Transect or Block result in singular model...
#Block explains variation in corolla diameter better than treatment or Recipient!
#ABOVEGROUND BIOMASS
#HR_final$log_biomass <- log(HR_final$AG_biomass_mg)
#HR_biomass_Model = lmer(log_biomass ~ watered + (1|Block) + (1|Recipient), data = HR_final, REML = T)

#Best lm
PL_AG_lm0 <- lm(log(AG_biomass_mg) ~ Treatment, data = HR_Fplants)
summary(PL_AG_lm0)
## 
## Call:
## lm(formula = log(AG_biomass_mg) ~ Treatment, data = HR_Fplants)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.25143 -0.55253  0.06928  0.50032  2.84495 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.89768    0.06211  62.752  < 2e-16 ***
## Treatment1  -0.24687    0.06211  -3.975 9.98e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8629 on 192 degrees of freedom
##   (119 observations deleted due to missingness)
## Multiple R-squared:  0.07602,    Adjusted R-squared:  0.07121 
## F-statistic:  15.8 on 1 and 192 DF,  p-value: 9.975e-05
plot(PL_AG_lm0)

hist(PL_AG_lm0$residuals)

#Transformation unnecessary? Better R2, marginally NS


#John Equivalent Model
PL_AGbio_lm1 <- lmer(log(AG_biomass_mg) ~ Treatment + (1|Transect) + (1|Recipient), data = HR_Fplants)
summary(PL_AGbio_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(AG_biomass_mg) ~ Treatment + (1 | Transect) + (1 | Recipient)
##    Data: HR_Fplants
## 
## REML criterion at convergence: 489.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8633 -0.5834  0.0400  0.6386  3.2827 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.02314  0.1521  
##  Transect  (Intercept) 0.13515  0.3676  
##  Residual              0.64836  0.8052  
## Number of obs: 194, groups:  Recipient, 21; Transect, 11
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   3.9302     0.1597  6.0246  24.613 2.82e-07 ***
## Treatment1   -0.2121     0.1562  5.5513  -1.357    0.227    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.523
r.squaredGLMM(PL_Cdiam_lm1)
##               R2m       R2c
## [1,] 0.0002562942 0.1768065
ranef(PL_Cdiam_lm1) #Both Transect or Block result in singular model
## $Recipient
##        (Intercept)
## HR_015 -0.04658301
## HR_017 -0.03486340
## HR_040  0.07490305
## HR_043  0.60260665
## HR_044  0.30224300
## HR_056  0.16373567
## HR_059  0.52757697
## HR_064 -0.10093706
## HR_071  0.29876080
## HR_080 -0.74365575
## HR_101 -0.49265780
## HR_112 -0.21373459
## HR_119  0.86840233
## HR_142 -0.23460017
## HR_145 -0.61801429
## HR_146  0.26895834
## HR_148  0.01899425
## HR_149  0.31092487
## HR_162 -0.85838358
## HR_180 -0.38254705
## HR_184  0.28887074
## 
## $Transect
##     (Intercept)
## 1  -0.081044091
## 2   0.007784553
## 3   1.239271939
## 4  -0.047248201
## 5  -0.675130655
## 6   0.266214548
## 7   0.530240400
## 8  -1.152611991
## 9  -0.087476500
## 10  0.429168022
## 11 -0.429168022
## 
## with conditional variances for "Recipient" "Transect"
# FECUNDITY
#HR_final2$log_seedprod <- log(HR_final2$total_est_seed_production)
#HR_seed_Model = lmer(log_seedprod ~ watered + (1|Block) + (1|Recipient), data = HR_final2, REML = T)

#lm
#filtered to individuals that produced seed
PL_fec_lm0 <- lm(log(total_est_seed_production+1) ~ Treatment, data = filter(HR_Fplants, surv_to_fruitprod == 1))
summary(PL_fec_lm0)
## 
## Call:
## lm(formula = log(total_est_seed_production + 1) ~ Treatment, 
##     data = filter(HR_Fplants, surv_to_fruitprod == 1))
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.61650 -0.77916  0.02851  0.90398  2.73085 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.44529    0.07393  33.074   <2e-16 ***
## Treatment1  -0.17121    0.07393  -2.316   0.0213 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.216 on 282 degrees of freedom
## Multiple R-squared:  0.01866,    Adjusted R-squared:  0.01518 
## F-statistic: 5.363 on 1 and 282 DF,  p-value: 0.02129
plot(PL_fec_lm0)

hist(PL_fec_lm0$residuals)

#Not filtering data (log+1):
PL_fec_lm0 <- lm(log(total_est_seed_production+1) ~ Treatment, data = HR_Fplants)
summary(PL_fec_lm0)
## 
## Call:
## lm(formula = log(total_est_seed_production + 1) ~ Treatment, 
##     data = HR_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.3234 -0.9116  0.1333  1.0854  3.0239 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.20804    0.07835  28.180   <2e-16 ***
## Treatment1  -0.11541    0.07835  -1.473    0.142    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.358 on 311 degrees of freedom
## Multiple R-squared:  0.006928,   Adjusted R-squared:  0.003734 
## F-statistic: 2.169 on 1 and 311 DF,  p-value: 0.1418
plot(PL_fec_lm0)

hist(PL_fec_lm0$residuals)

#John's equivalent model
#Excludes plants that didn't survive to produce seeds!!
PL_fec_lm1 <- lmer(log(total_est_seed_production+1) ~ Treatment + (1|Recipient) + (1|Transect), data = filter(HR_Fplants, surv_to_fruitprod == 1))
summary(PL_fec_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(total_est_seed_production + 1) ~ Treatment + (1 | Recipient) +  
##     (1 | Transect)
##    Data: filter(HR_Fplants, surv_to_fruitprod == 1)
## 
## REML criterion at convergence: 903.6
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.71471 -0.56565  0.02569  0.70669  2.27623 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.1179   0.3434  
##  Transect  (Intercept) 0.1499   0.3872  
##  Residual              1.2596   1.1223  
## Number of obs: 284, groups:  Recipient, 21; Transect, 11
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   2.4484     0.1829  7.2862  13.387 2.15e-06 ***
## Treatment1   -0.1723     0.1668  5.0610  -1.033    0.348    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.506
r.squaredGLMM(PL_fec_lm1)
##             R2m       R2c
## [1,] 0.01823951 0.1903948
#Not filtering -log+1
PL_fec_lm1 <- lmer(log(total_est_seed_production+1) ~ Treatment + (1|Recipient) + (1|Transect), data = HR_Fplants)
summary(PL_fec_lm1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: log(total_est_seed_production + 1) ~ Treatment + (1 | Recipient) +  
##     (1 | Transect)
##    Data: HR_Fplants
## 
## REML criterion at convergence: 1071.4
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.13437 -0.63770  0.05493  0.72896  2.31589 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev.
##  Recipient (Intercept) 0.16989  0.4122  
##  Transect  (Intercept) 0.06853  0.2618  
##  Residual              1.63454  1.2785  
## Number of obs: 313, groups:  Recipient, 21; Transect, 11
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)   2.2043     0.1554  5.4535  14.184 1.64e-05 ***
## Treatment1   -0.1158     0.1267  2.4071  -0.914    0.443    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.387
r.squaredGLMM(PL_fec_lm1)
##              R2m       R2c
## [1,] 0.006848361 0.1332732

GxE Effects in BO

#FFD
GxE_FFD_lm0 <- lm(yday(FFD) ~ Recipient*Treatment + Transect, data = HR_allplants)
summary(GxE_FFD_lm0)
## 
## Call:
## lm(formula = yday(FFD) ~ Recipient * Treatment + Transect, data = HR_allplants)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -13.6972  -2.6778  -0.3336   2.7852  27.9242 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            99.59641    0.73410 135.672  < 2e-16 ***
## Recipient1             -1.68440    0.74376  -2.265 0.023839 *  
## Recipient2              1.03281    0.79022   1.307 0.191649    
## Recipient3              2.48113    0.79338   3.127 0.001838 ** 
## Recipient4              0.49363    0.77905   0.634 0.526531    
## Recipient5              1.06342    0.86513   1.229 0.219412    
## Recipient6              0.56528    0.79010   0.715 0.474570    
## Recipient7             -0.35713    0.77905  -0.458 0.646796    
## Recipient8              0.61924    0.75175   0.824 0.410377    
## Recipient9              1.55659    0.79072   1.969 0.049402 *  
## Recipient10             0.70205    0.85528   0.821 0.412022    
## Recipient11            -1.75213    0.82231  -2.131 0.033463 *  
## Recipient12            -0.72139    0.81814  -0.882 0.378225    
## Recipient13            -2.32128    0.79621  -2.915 0.003667 ** 
## Recipient14             1.00185    0.77347   1.295 0.195662    
## Recipient15             0.47366    0.76390   0.620 0.535431    
## Recipient16            -3.80340    0.77881  -4.884 1.30e-06 ***
## Recipient17            -1.63445    0.78353  -2.086 0.037344 *  
## Recipient18            -1.37498    0.75189  -1.829 0.067878 .  
## Recipient19             1.34601    0.77078   1.746 0.081205 .  
## Recipient20             1.13555    0.83116   1.366 0.172315    
## Treatment1             -3.39482    0.30242 -11.225  < 2e-16 ***
## Transect               -1.61061    0.09129 -17.643  < 2e-16 ***
## Recipient1:Treatment1  -1.16709    0.74376  -1.569 0.117062    
## Recipient2:Treatment1  -2.94933    0.79031  -3.732 0.000206 ***
## Recipient3:Treatment1  -0.56407    0.79340  -0.711 0.477358    
## Recipient4:Treatment1   0.18848    0.77912   0.242 0.808916    
## Recipient5:Treatment1  -0.37889    0.86470  -0.438 0.661393    
## Recipient6:Treatment1  -0.39984    0.79008  -0.506 0.612961    
## Recipient7:Treatment1   1.10763    0.77914   1.422 0.155589    
## Recipient8:Treatment1   1.77869    0.75185   2.366 0.018268 *  
## Recipient9:Treatment1  -0.56238    0.79038  -0.712 0.477000    
## Recipient10:Treatment1 -0.43570    0.85521  -0.509 0.610590    
## Recipient11:Treatment1  0.44273    0.82275   0.538 0.590680    
## Recipient12:Treatment1 -1.76343    0.81811  -2.156 0.031467 *  
## Recipient13:Treatment1 -0.38035    0.79621  -0.478 0.633016    
## Recipient14:Treatment1  1.01916    0.77347   1.318 0.188061    
## Recipient15:Treatment1  3.14048    0.76387   4.111 4.41e-05 ***
## Recipient16:Treatment1 -0.66991    0.77873  -0.860 0.389948    
## Recipient17:Treatment1 -0.30465    0.78351  -0.389 0.697525    
## Recipient18:Treatment1 -2.90815    0.75198  -3.867 0.000120 ***
## Recipient19:Treatment1  2.50546    0.77081   3.250 0.001208 ** 
## Recipient20:Treatment1  1.83040    0.83119   2.202 0.027984 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.666 on 691 degrees of freedom
##   (106 observations deleted due to missingness)
## Multiple R-squared:  0.4379, Adjusted R-squared:  0.4037 
## F-statistic: 12.82 on 42 and 691 DF,  p-value: < 2.2e-16
plot(GxE_FFD_lm0)

hist(GxE_FFD_lm0$residuals)

Anova(GxE_FFD_lm0, type = 3)
## Anova Table (Type III tests)
## 
## Response: yday(FFD)
##                     Sum Sq  Df    F value    Pr(>F)    
## (Intercept)         400796   1 18406.8428 < 2.2e-16 ***
## Recipient             1644  20     3.7740 6.925e-08 ***
## Treatment             2744   1   126.0094 < 2.2e-16 ***
## Transect              6778   1   311.2851 < 2.2e-16 ***
## Recipient:Treatment   1689  20     3.8782 3.353e-08 ***
## Residuals            15046 691                         
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Flowering Duration
GxE_Fdur_lm0 <- lm(fl_duration ~ Recipient*Treatment + Transect, data = HR_allplants)
summary(GxE_Fdur_lm0)
## 
## Call:
## lm(formula = fl_duration ~ Recipient * Treatment + Transect, 
##     data = HR_allplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -29.768  -5.308   0.209   5.564  39.307 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            20.37205    1.61116  12.644  < 2e-16 ***
## Recipient1             -1.25377    1.63237  -0.768 0.442709    
## Recipient2              6.76317    1.73433   3.900 0.000106 ***
## Recipient3             -3.56284    1.74128  -2.046 0.041124 *  
## Recipient4             -2.62219    1.70983  -1.534 0.125586    
## Recipient5              0.27464    1.89874   0.145 0.885034    
## Recipient6              2.79854    1.73406   1.614 0.107014    
## Recipient7              6.80917    1.70982   3.982 7.55e-05 ***
## Recipient8             -6.30097    1.64990  -3.819 0.000146 ***
## Recipient9             -1.22406    1.73544  -0.705 0.480842    
## Recipient10             1.18746    1.87713   0.633 0.527209    
## Recipient11             0.76944    1.80476   0.426 0.669994    
## Recipient12             5.10422    1.79562   2.843 0.004607 ** 
## Recipient13            -2.11190    1.74749  -1.209 0.227256    
## Recipient14             3.83271    1.69758   2.258 0.024272 *  
## Recipient15            -2.99809    1.67657  -1.788 0.074178 .  
## Recipient16             3.19089    1.70930   1.867 0.062356 .  
## Recipient17            -3.52246    1.71966  -2.048 0.040903 *  
## Recipient18             0.74466    1.65022   0.451 0.651952    
## Recipient19             0.32515    1.69167   0.192 0.847638    
## Recipient20            -4.12252    1.82420  -2.260 0.024138 *  
## Treatment1              0.73851    0.66374   1.113 0.266247    
## Transect                0.41115    0.20035   2.052 0.040533 *  
## Recipient1:Treatment1   3.94686    1.63236   2.418 0.015869 *  
## Recipient2:Treatment1   5.96038    1.73452   3.436 0.000625 ***
## Recipient3:Treatment1  -0.17471    1.74132  -0.100 0.920112    
## Recipient4:Treatment1  -3.62950    1.70998  -2.123 0.034148 *  
## Recipient5:Treatment1   0.60750    1.89780   0.320 0.748983    
## Recipient6:Treatment1  -0.91366    1.73403  -0.527 0.598434    
## Recipient7:Treatment1  -2.21084    1.71001  -1.293 0.196485    
## Recipient8:Treatment1   1.06337    1.65012   0.644 0.519518    
## Recipient9:Treatment1  -2.39779    1.73469  -1.382 0.167338    
## Recipient10:Treatment1  7.17235    1.87696   3.821 0.000145 ***
## Recipient11:Treatment1  0.04784    1.80574   0.026 0.978870    
## Recipient12:Treatment1 -5.60797    1.79554  -3.123 0.001863 ** 
## Recipient13:Treatment1  3.16224    1.74748   1.810 0.070792 .  
## Recipient14:Treatment1 -2.77916    1.69758  -1.637 0.102059    
## Recipient15:Treatment1 -2.99449    1.67651  -1.786 0.074513 .  
## Recipient16:Treatment1 -0.67219    1.70912  -0.393 0.694224    
## Recipient17:Treatment1  0.99067    1.71960   0.576 0.564731    
## Recipient18:Treatment1  2.48159    1.65040   1.504 0.133135    
## Recipient19:Treatment1 -4.77718    1.69173  -2.824 0.004882 ** 
## Recipient20:Treatment1 -0.55840    1.82425  -0.306 0.759624    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 10.24 on 691 degrees of freedom
##   (106 observations deleted due to missingness)
## Multiple R-squared:  0.1984, Adjusted R-squared:  0.1496 
## F-statistic: 4.071 on 42 and 691 DF,  p-value: 3.38e-15
plot(GxE_Fdur_lm0)

hist(GxE_Fdur_lm0$residuals)

#Significant GxE effect when log-transformed but not sqrt()

Anova(GxE_Fdur_lm0, type = 3)
## Anova Table (Type III tests)
## 
## Response: fl_duration
##                     Sum Sq  Df  F value    Pr(>F)    
## (Intercept)          16769   1 159.8787 < 2.2e-16 ***
## Recipient             9340  20   4.4526 5.830e-10 ***
## Treatment              130   1   1.2380   0.26625    
## Transect               442   1   4.2112   0.04053 *  
## Recipient:Treatment   7135  20   3.4013 8.965e-07 ***
## Residuals            72476 691                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Corolla Diam
GxE_Cd_lm0 <- lm(corolla_diam_mm ~ Recipient*Treatment, data = HR_Fplants)
summary(GxE_Cd_lm0)
## 
## Call:
## lm(formula = corolla_diam_mm ~ Recipient * Treatment, data = HR_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -5.2191 -1.2667  0.1492  1.5244  5.0489 
## 
## Coefficients: (3 not defined because of singularities)
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)            22.59472    0.83457  27.074   <2e-16 ***
## Recipient1             -0.49193    1.11383  -0.442   0.6593    
## Recipient2             -0.08705    1.08492  -0.080   0.9361    
## Recipient3             -0.34678    1.50104  -0.231   0.8176    
## Recipient4              0.73989    1.13791   0.650   0.5164    
## Recipient5              0.04016    1.09222   0.037   0.9707    
## Recipient6             -0.10928    1.09222  -0.100   0.9204    
## Recipient7              1.18347    1.24351   0.952   0.3425    
## Recipient8              7.49224   14.81676   0.506   0.6137    
## Recipient9             -0.17972    1.10153  -0.163   0.8706    
## Recipient10            -3.30097    1.50104  -2.199   0.0292 *  
## Recipient11            -1.04161    0.77654  -1.341   0.1815    
## Recipient12            -1.11247    1.09222  -1.019   0.3098    
## Recipient13             1.76884    1.49573   1.183   0.2385    
## Recipient14            -0.49130    1.16551  -0.422   0.6739    
## Recipient15            -1.16203    1.50104  -0.774   0.4399    
## Recipient16             0.61332    0.82102   0.747   0.4560    
## Recipient17            -0.74111    1.14487  -0.647   0.5182    
## Recipient18             0.03632    1.05937   0.034   0.9727    
## Recipient19            -2.68172    1.23711  -2.168   0.0315 *  
## Recipient20            -1.29038    0.94193  -1.370   0.1724    
## Treatment1             -0.49467    0.84070  -0.588   0.5570    
## Recipient1:Treatment1   1.16021    1.13832   1.019   0.3095    
## Recipient2:Treatment1   0.46333    1.10328   0.420   0.6750    
## Recipient3:Treatment1   0.10160    1.51560   0.067   0.9466    
## Recipient4:Treatment1   0.24661    1.15544   0.213   0.8312    
## Recipient5:Treatment1   1.25954    1.11215   1.133   0.2589    
## Recipient6:Treatment1   1.19735    1.11215   1.077   0.2831    
## Recipient7:Treatment1   0.11735    1.26105   0.093   0.9260    
## Recipient8:Treatment1  -8.15417   14.78796  -0.551   0.5820    
## Recipient9:Treatment1   0.49267    1.12344   0.439   0.6615    
## Recipient10:Treatment1  1.81242    1.51560   1.196   0.2333    
## Recipient11:Treatment1       NA         NA      NA       NA    
## Recipient12:Treatment1  1.32717    1.11215   1.193   0.2343    
## Recipient13:Treatment1 -0.58978    1.50911  -0.391   0.6964    
## Recipient14:Treatment1 -0.40425    1.18893  -0.340   0.7342    
## Recipient15:Treatment1 -0.90065    1.51560  -0.594   0.5531    
## Recipient16:Treatment1       NA         NA      NA       NA    
## Recipient17:Treatment1  1.48594    1.16390   1.277   0.2034    
## Recipient18:Treatment1  0.95150    1.07990   0.881   0.3794    
## Recipient19:Treatment1  0.22767    1.25325   0.182   0.8561    
## Recipient20:Treatment1       NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.378 on 179 degrees of freedom
##   (95 observations deleted due to missingness)
## Multiple R-squared:  0.2346, Adjusted R-squared:  0.07213 
## F-statistic: 1.444 on 38 and 179 DF,  p-value: 0.05915
plot(GxE_Cd_lm0)
## Warning: not plotting observations with leverage one:
##   168, 170, 208, 210

hist(GxE_Cd_lm0$residuals)

#Anova(GxE_Cd_lm0, type = 3)


##Using the smaller data frame (fitness plants only) in the following models results in aliased coefficients. Report only GxE effects for flowering date and duration?


#Biomass
GxE_BIO_lm1<- lm(log(AG_biomass_mg) ~ Treatment*Recipient, data = HR_Fplants)
summary(GxE_BIO_lm1)
## 
## Call:
## lm(formula = log(AG_biomass_mg) ~ Treatment * Recipient, data = HR_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.0774 -0.5035  0.0619  0.4844  1.7614 
## 
## Coefficients: (1 not defined because of singularities)
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             4.115569   0.323637  12.717   <2e-16 ***
## Treatment1             -0.472181   0.336789  -1.402   0.1629    
## Recipient1             -0.419508   0.425594  -0.986   0.3258    
## Recipient2             -0.367240   0.408598  -0.899   0.3702    
## Recipient3             -0.492790   0.426274  -1.156   0.2495    
## Recipient4             -0.163029   0.402150  -0.405   0.6858    
## Recipient5             -0.216522   0.429744  -0.504   0.6151    
## Recipient6              0.008444   0.439530   0.019   0.9847    
## Recipient7              0.149791   0.395035   0.379   0.7051    
## Recipient8             -0.652941   0.407818  -1.601   0.1114    
## Recipient9              0.040315   0.457698   0.088   0.9299    
## Recipient10            -0.271561   0.418118  -0.649   0.5170    
## Recipient11             0.260379   0.416176   0.626   0.5325    
## Recipient12            -0.173062   0.442592  -0.391   0.6963    
## Recipient13            -0.408033   0.429430  -0.950   0.3435    
## Recipient14             0.370210   0.390863   0.947   0.3450    
## Recipient15            -0.738338   0.407818  -1.810   0.0722 .  
## Recipient16             0.032049   0.407818   0.079   0.9375    
## Recipient17             4.794239   6.540281   0.733   0.4647    
## Recipient18            -0.025786   0.464911  -0.055   0.9558    
## Recipient19            -0.724409   0.402150  -1.801   0.0736 .  
## Recipient20            -0.748792   0.561597  -1.333   0.1844    
## Treatment1:Recipient1   0.765906   0.440961   1.737   0.0844 .  
## Treatment1:Recipient2   0.614011   0.424580   1.446   0.1502    
## Treatment1:Recipient3   0.579335   0.445530   1.300   0.1954    
## Treatment1:Recipient4   0.123129   0.419299   0.294   0.7694    
## Treatment1:Recipient5   0.400703   0.451850   0.887   0.3766    
## Treatment1:Recipient6  -0.290303   0.461168  -0.629   0.5300    
## Treatment1:Recipient7  -0.009268   0.412481  -0.022   0.9821    
## Treatment1:Recipient8   0.096261   0.426008   0.226   0.8215    
## Treatment1:Recipient9   0.068178   0.472020   0.144   0.8853    
## Treatment1:Recipient10  0.653507   0.435879   1.499   0.1359    
## Treatment1:Recipient11  0.633953   0.435879   1.454   0.1479    
## Treatment1:Recipient12  0.650419   0.461168   1.410   0.1605    
## Treatment1:Recipient13  0.334780   0.445530   0.751   0.4536    
## Treatment1:Recipient14 -0.315279   0.407541  -0.774   0.4404    
## Treatment1:Recipient15 -0.154134   0.426008  -0.362   0.7180    
## Treatment1:Recipient16 -0.015380   0.426008  -0.036   0.9712    
## Treatment1:Recipient17 -4.817874   6.514562  -0.740   0.4607    
## Treatment1:Recipient18  0.389227   0.490950   0.793   0.4291    
## Treatment1:Recipient19 -0.058952   0.419299  -0.141   0.8884    
## Treatment1:Recipient20        NA         NA      NA       NA    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.825 on 153 degrees of freedom
##   (119 observations deleted due to missingness)
## Multiple R-squared:  0.327,  Adjusted R-squared:  0.151 
## F-statistic: 1.858 on 40 and 153 DF,  p-value: 0.004018
plot(GxE_BIO_lm1)

hist(GxE_BIO_lm1$residuals)

#Anova(GxE_BIO_lm1, type = 3)


#Est. Fecundity
#Filtered version - high VIFs!!!
GxE_FEC_lm1 <- lm(log(total_est_seed_production+1) ~ Treatment*Recipient + Transect, data = filter(HR_Fplants, surv_to_fruitprod == 1))
summary(GxE_FEC_lm1)
## 
## Call:
## lm(formula = log(total_est_seed_production + 1) ~ Treatment * 
##     Recipient + Transect, data = filter(HR_Fplants, surv_to_fruitprod == 
##     1))
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.71723 -0.62894  0.09995  0.71680  2.43034 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             1.715445   0.274086   6.259 1.76e-09 ***
## Treatment1              0.094958   0.119968   0.792 0.429413    
## Recipient1             -0.228667   0.331213  -0.690 0.490611    
## Recipient2             -0.894136   0.292619  -3.056 0.002499 ** 
## Recipient3             -0.479598   0.292734  -1.638 0.102656    
## Recipient4              0.291997   0.292726   0.998 0.319517    
## Recipient5              0.036557   0.292948   0.125 0.900794    
## Recipient6              0.480154   0.319189   1.504 0.133816    
## Recipient7             -0.142496   0.299384  -0.476 0.634532    
## Recipient8              0.224889   0.299388   0.751 0.453288    
## Recipient9             -0.202093   0.365947  -0.552 0.581292    
## Recipient10            -0.946304   0.337339  -2.805 0.005439 ** 
## Recipient11             0.976927   0.292948   3.335 0.000988 ***
## Recipient12             0.328375   0.344842   0.952 0.341925    
## Recipient13             0.208850   0.292616   0.714 0.476083    
## Recipient14             0.804152   0.292619   2.748 0.006447 ** 
## Recipient15             0.012294   0.308629   0.040 0.968259    
## Recipient16             0.120451   0.318910   0.378 0.705988    
## Recipient17             0.184247   0.579385   0.318 0.750756    
## Recipient18             0.002639   0.299688   0.009 0.992982    
## Recipient19            -0.683815   0.292619  -2.337 0.020266 *  
## Recipient20             0.253899   0.299396   0.848 0.397258    
## Transect                0.095100   0.034438   2.762 0.006197 ** 
## Treatment1:Recipient1   0.381800   0.331243   1.153 0.250205    
## Treatment1:Recipient2   0.507096   0.292652   1.733 0.084417 .  
## Treatment1:Recipient3   0.092318   0.292812   0.315 0.752820    
## Treatment1:Recipient4   0.281532   0.292669   0.962 0.337041    
## Treatment1:Recipient5  -0.086636   0.292846  -0.296 0.767606    
## Treatment1:Recipient6   0.122494   0.319302   0.384 0.701591    
## Treatment1:Recipient7   0.094564   0.299389   0.316 0.752385    
## Treatment1:Recipient8  -0.545145   0.299409  -1.821 0.069887 .  
## Treatment1:Recipient9  -0.168220   0.365777  -0.460 0.646004    
## Treatment1:Recipient10  0.234377   0.337284   0.695 0.487791    
## Treatment1:Recipient11  0.016821   0.292846   0.057 0.954242    
## Treatment1:Recipient12  0.205253   0.344781   0.595 0.552193    
## Treatment1:Recipient13  0.780398   0.292604   2.667 0.008170 ** 
## Treatment1:Recipient14 -0.318134   0.292652  -1.087 0.278090    
## Treatment1:Recipient15 -0.691368   0.308706  -2.240 0.026032 *  
## Treatment1:Recipient16 -0.173461   0.318878  -0.544 0.586963    
## Treatment1:Recipient17 -0.352214   0.579363  -0.608 0.543804    
## Treatment1:Recipient18 -0.143109   0.299593  -0.478 0.633313    
## Treatment1:Recipient19  0.112145   0.292652   0.383 0.701908    
## Treatment1:Recipient20 -0.511663   0.299384  -1.709 0.088728 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.13 on 241 degrees of freedom
## Multiple R-squared:  0.2752, Adjusted R-squared:  0.1489 
## F-statistic: 2.179 on 42 and 241 DF,  p-value: 0.0001356
plot(GxE_FEC_lm1 )
## Warning: not plotting observations with leverage one:
##   181

hist(GxE_FEC_lm1 $residuals)

#poor sample sizes...

#Anova(GxE_FEC_lm1, type = 3)


#not filtered version
GxE_FEC_lm1 <- lm(log(total_est_seed_production+1) ~ Treatment*Recipient + Transect, data = HR_Fplants)
summary(GxE_FEC_lm1)
## 
## Call:
## lm(formula = log(total_est_seed_production + 1) ~ Treatment * 
##     Recipient + Transect, data = HR_Fplants)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.7434 -0.8080  0.0725  0.7528  3.3461 
## 
## Coefficients:
##                        Estimate Std. Error t value Pr(>|t|)    
## (Intercept)             1.68665    0.28920   5.832 1.56e-08 ***
## Treatment1              0.07420    0.12382   0.599  0.54947    
## Recipient1             -0.32369    0.32065  -1.009  0.31364    
## Recipient2             -0.65118    0.32069  -2.031  0.04328 *  
## Recipient3             -0.24135    0.32084  -0.752  0.45255    
## Recipient4              0.54437    0.32073   1.697  0.09080 .  
## Recipient5              0.29363    0.32092   0.915  0.36102    
## Recipient6              0.21469    0.32065   0.670  0.50372    
## Recipient7             -0.02445    0.32065  -0.076  0.93928    
## Recipient8              0.36392    0.32069   1.135  0.25745    
## Recipient9             -0.61732    0.32069  -1.925  0.05528 .  
## Recipient10            -0.91073    0.33843  -2.691  0.00757 ** 
## Recipient11             1.23400    0.32092   3.845  0.00015 ***
## Recipient12            -0.21276    0.32065  -0.664  0.50755    
## Recipient13             0.45651    0.32065   1.424  0.15569    
## Recipient14             1.04711    0.32069   3.265  0.00124 ** 
## Recipient15            -0.01768    0.32069  -0.055  0.95607    
## Recipient16             0.01239    0.32069   0.039  0.96921    
## Recipient17            -1.02934    0.32819  -3.136  0.00190 ** 
## Recipient18             0.13524    0.32092   0.421  0.67379    
## Recipient19            -0.44086    0.32069  -1.375  0.17035    
## Recipient20             0.40003    0.32069   1.247  0.21332    
## Transect                0.06686    0.03629   1.842  0.06651 .  
## Treatment1:Recipient1   0.66758    0.32065   2.082  0.03829 *  
## Treatment1:Recipient2   0.44548    0.32069   1.389  0.16593    
## Treatment1:Recipient3   0.02600    0.32084   0.081  0.93548    
## Treatment1:Recipient4   0.22933    0.32072   0.715  0.47520    
## Treatment1:Recipient5  -0.13413    0.32091  -0.418  0.67630    
## Treatment1:Recipient6  -0.44754    0.32065  -1.396  0.16394    
## Treatment1:Recipient7  -0.09196    0.32065  -0.287  0.77449    
## Treatment1:Recipient8  -0.71068    0.32069  -2.216  0.02752 *  
## Treatment1:Recipient9   0.42834    0.32069   1.336  0.18277    
## Treatment1:Recipient10  0.24637    0.33844   0.728  0.46727    
## Treatment1:Recipient11 -0.03067    0.32091  -0.096  0.92392    
## Treatment1:Recipient12  0.28945    0.32065   0.903  0.36750    
## Treatment1:Recipient13  0.72349    0.32065   2.256  0.02485 *  
## Treatment1:Recipient14 -0.37975    0.32069  -1.184  0.23739    
## Treatment1:Recipient15 -0.48006    0.32069  -1.497  0.13557    
## Treatment1:Recipient16 -0.58609    0.32069  -1.828  0.06871 .  
## Treatment1:Recipient17  0.76714    0.32819   2.337  0.02014 *  
## Treatment1:Recipient18 -0.31508    0.32091  -0.982  0.32707    
## Treatment1:Recipient19  0.05053    0.32069   0.158  0.87492    
## Treatment1:Recipient20 -0.67010    0.32069  -2.090  0.03759 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.247 on 270 degrees of freedom
## Multiple R-squared:  0.2734, Adjusted R-squared:  0.1604 
## F-statistic: 2.419 on 42 and 270 DF,  p-value: 1.208e-05
plot(GxE_FEC_lm1)

hist(GxE_FEC_lm1$residuals)

#Anova(GxE_FEC_lm1, type = 3)

Visualizations: GxE Effects - HR

library(RColorBrewer)

## Hastings Reservation 

HR_filter_reps <- HR_allplants %>% #Use genotype means in each treatment to make reaction norms
  filter(!is.na(FFD)) %>% 
  mutate(Treatment = fct_recode(Treatment, "Watered" = "watered", "Ambient" = "ambient")) %>% 
  group_by(Recipient, Treatment) %>% 
  summarize(
    mean_FFD = mean(yday(FFD)),
    mean_Fdur = mean(fl_duration)
  ) %>% 
  ungroup()
## `summarise()` has grouped output by 'Recipient'. You can override using the
## `.groups` argument.
colpal2 <- colorRampPalette(brewer.pal(8, "Accent"))(21)

ggplot(data = HR_filter_reps, aes(x=Treatment, y=mean_FFD, group = Recipient)) + 
  geom_line(aes(color = Recipient), linewidth = 1) + 
  labs(x= "Treatment", y = "First Flowering Date") +
  scale_x_discrete(expand = c(.1, .1)) +
  scale_color_manual(values = colpal2) +
  theme_classic(base_size = 16) + 
  theme(legend.position = "none")

ggplot(data = HR_filter_reps, aes(x=Treatment, y=mean_Fdur, group = Recipient)) + 
  geom_line(aes(color = Recipient), linewidth = 1) + 
  labs(x= "Treatment", y = "Flowering Duration") +
  scale_x_discrete(expand = c(.1, .1)) +
  scale_color_manual(values = colpal2) +
  theme_classic(base_size = 16) + 
  theme(legend.position = "none")

##Bodega Bay

BB_filter_reps <- BB_allplants %>% #Use genotype means in each treatment to make reaction norms
  filter(!is.na(FFD)) %>% 
  mutate(Treatment = fct_recode(Treatment, "Watered" = "watered", "Ambient" = "ambient")) %>% 
  group_by(Recipient, Treatment) %>% 
  summarize(
    mean_FFD = mean(yday(FFD)),
    mean_Fdur = mean(fl_duration)
  ) %>% 
  ungroup()
## `summarise()` has grouped output by 'Recipient'. You can override using the
## `.groups` argument.
ggplot(data = BB_filter_reps, aes(x=Treatment, y=mean_FFD, group = Recipient)) + 
  geom_line(aes(color = Recipient), linewidth = 1) + 
  labs(x= "Treatment", y = "First Flowering Date") +
  scale_x_discrete(expand = c(.1, .1)) +
  scale_color_manual(values = colpal2) +
  theme_classic(base_size = 16) + 
  theme(legend.position = "none")

ggplot(data = BB_filter_reps, aes(x=Treatment, y=mean_Fdur, group = Recipient)) + 
  geom_line(aes(color = Recipient), linewidth = 1) + 
  labs(x= "Treatment", y = "Flowering Duration") +
  scale_x_discrete(expand = c(.1, .1)) +
  scale_color_manual(values = colpal2) +
  theme_classic(base_size = 16) + 
  theme(legend.position = "none")

Estimating genotypic variation in the effect of watering

Random slope models

HR_FFD_m1mc <- lmer(yday(FFD) ~ Treatment + (1|Transect) + (1+Treatment|Recipient), data = HR_allplants, REML = FALSE)
summary(HR_FFD_m1mc)
## Linear mixed model fit by maximum likelihood . t-tests use Satterthwaite's
##   method [lmerModLmerTest]
## Formula: yday(FFD) ~ Treatment + (1 | Transect) + (1 + Treatment | Recipient)
##    Data: HR_allplants
## 
##      AIC      BIC   logLik deviance df.resid 
##   4447.0   4479.2  -2216.5   4433.0      727 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0636 -0.5876 -0.1420  0.6312  5.8611 
## 
## Random effects:
##  Groups    Name        Variance Std.Dev. Corr
##  Recipient (Intercept)  2.028   1.424        
##            Treatment1   1.934   1.391    0.50
##  Transect  (Intercept) 15.080   3.883        
##  Residual              21.640   4.652        
## Number of obs: 734, groups:  Recipient, 21; Transect, 11
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   87.081      1.560 11.155  55.820 5.22e-15 ***
## Treatment1     1.030      1.559 11.114   0.661    0.522    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Treatment1 -0.585
r.squaredGLMM(HR_FFD_m1mc)
##             R2m       R2c
## [1,] 0.02434909 0.4857516
ranef(HR_FFD_m1mc)
## $Recipient
##        (Intercept)  Treatment1
## HR_015 -1.31654779 -1.01033814
## HR_017  0.34665660 -1.83195615
## HR_040  1.66194686 -0.18098656
## HR_043  0.26563045  0.07640315
## HR_044  0.73371122  0.01764947
## HR_056  0.53016213 -0.01358930
## HR_059 -0.01819183  0.78485753
## HR_064  0.80572766  1.44680974
## HR_071  1.09312557 -0.08374612
## HR_080  0.15146423 -0.46109310
## HR_101 -1.32522051 -0.09247077
## HR_112 -0.68386955 -1.25198033
## HR_119 -1.48927122 -0.43289711
## HR_142  0.86264552  0.84489603
## HR_145  0.87133923  2.38270854
## HR_146 -3.20741981 -1.37309067
## HR_148 -1.20683536 -0.42047213
## HR_149 -1.49897831 -2.37981166
## HR_162  1.38652512  2.01996162
## HR_180  1.02816752  1.38857959
## HR_184  1.00923228  0.57056638
## 
## $Transect
##    (Intercept)
## 1    7.2968165
## 2    4.5571976
## 3    1.6909934
## 4    2.3691102
## 5    0.0389839
## 6   -1.8878329
## 7   -3.0499922
## 8   -5.8127628
## 9   -5.2025138
## 10   0.8234272
## 11  -0.8234272
## 
## with conditional variances for "Recipient" "Transect"